places/bookmark_sync/
mod.rspub mod engine;
mod incoming;
pub mod record;
#[cfg(test)]
mod tests;
use crate::error::*;
pub use engine::BookmarksSyncEngine;
use rusqlite::types::{ToSql, ToSqlOutput};
use rusqlite::Result as RusqliteResult;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum SyncedBookmarkKind {
Bookmark = 1, Query = 2, Folder = 3, Livemark = 4, Separator = 5, }
impl SyncedBookmarkKind {
#[inline]
pub fn from_u8(v: u8) -> Result<Self> {
match v {
1 => Ok(SyncedBookmarkKind::Bookmark),
2 => Ok(SyncedBookmarkKind::Query),
3 => Ok(SyncedBookmarkKind::Folder),
4 => Ok(SyncedBookmarkKind::Livemark),
5 => Ok(SyncedBookmarkKind::Separator),
_ => Err(Error::UnsupportedSyncedBookmarkKind(v)),
}
}
}
impl From<SyncedBookmarkKind> for dogear::Kind {
#[inline]
fn from(kind: SyncedBookmarkKind) -> dogear::Kind {
match kind {
SyncedBookmarkKind::Bookmark => dogear::Kind::Bookmark,
SyncedBookmarkKind::Query => dogear::Kind::Query,
SyncedBookmarkKind::Folder => dogear::Kind::Folder,
SyncedBookmarkKind::Livemark => dogear::Kind::Livemark,
SyncedBookmarkKind::Separator => dogear::Kind::Separator,
}
}
}
impl From<dogear::Kind> for SyncedBookmarkKind {
#[inline]
fn from(kind: dogear::Kind) -> SyncedBookmarkKind {
match kind {
dogear::Kind::Bookmark => SyncedBookmarkKind::Bookmark,
dogear::Kind::Query => SyncedBookmarkKind::Query,
dogear::Kind::Folder => SyncedBookmarkKind::Folder,
dogear::Kind::Livemark => SyncedBookmarkKind::Livemark,
dogear::Kind::Separator => SyncedBookmarkKind::Separator,
}
}
}
impl ToSql for SyncedBookmarkKind {
#[inline]
fn to_sql(&self) -> RusqliteResult<ToSqlOutput<'_>> {
Ok(ToSqlOutput::from(*self as u8))
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum SyncedBookmarkValidity {
Valid = 1, Reupload = 2, Replace = 3, }
impl SyncedBookmarkValidity {
#[inline]
pub fn from_u8(v: u8) -> Result<Self> {
match v {
1 => Ok(SyncedBookmarkValidity::Valid),
2 => Ok(SyncedBookmarkValidity::Reupload),
3 => Ok(SyncedBookmarkValidity::Replace),
_ => Err(Error::UnsupportedSyncedBookmarkValidity(v)),
}
}
}
impl From<SyncedBookmarkValidity> for dogear::Validity {
fn from(validity: SyncedBookmarkValidity) -> dogear::Validity {
match validity {
SyncedBookmarkValidity::Valid => dogear::Validity::Valid,
SyncedBookmarkValidity::Reupload => dogear::Validity::Reupload,
SyncedBookmarkValidity::Replace => dogear::Validity::Replace,
}
}
}
impl ToSql for SyncedBookmarkValidity {
fn to_sql(&self) -> RusqliteResult<ToSqlOutput<'_>> {
Ok(ToSqlOutput::from(*self as u8))
}
}