mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
put synctoken into common module
This commit is contained in:
@@ -8,7 +8,7 @@ use rustical_dav::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use rustical_store::{
|
use rustical_store::{
|
||||||
calendar::{format_synctoken, parse_synctoken},
|
synctoken::{format_synctoken, parse_synctoken},
|
||||||
CalendarStore,
|
CalendarStore,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use rustical_dav::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use rustical_store::{
|
use rustical_store::{
|
||||||
addressbook::{format_synctoken, parse_synctoken},
|
synctoken::{format_synctoken, parse_synctoken},
|
||||||
AddressbookStore,
|
AddressbookStore,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::synctoken::format_synctoken;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -15,18 +16,3 @@ impl Addressbook {
|
|||||||
format_synctoken(self.synctoken)
|
format_synctoken(self.synctoken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make nicer
|
|
||||||
const SYNC_NAMESPACE: &str = "github.com/lennart-k/rustical/ns/";
|
|
||||||
|
|
||||||
pub fn format_synctoken(synctoken: i64) -> String {
|
|
||||||
format!("{}{}", SYNC_NAMESPACE, synctoken)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_synctoken(synctoken: &str) -> Option<i64> {
|
|
||||||
if !synctoken.starts_with(SYNC_NAMESPACE) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let (_, synctoken) = synctoken.split_at(SYNC_NAMESPACE.len());
|
|
||||||
synctoken.parse::<i64>().ok()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::synctoken::format_synctoken;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -19,17 +20,3 @@ impl Calendar {
|
|||||||
format_synctoken(self.synctoken)
|
format_synctoken(self.synctoken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SYNC_NAMESPACE: &str = "github.com/lennart-k/rustical/ns/";
|
|
||||||
|
|
||||||
pub fn format_synctoken(synctoken: i64) -> String {
|
|
||||||
format!("{}{}", SYNC_NAMESPACE, synctoken)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_synctoken(synctoken: &str) -> Option<i64> {
|
|
||||||
if !synctoken.starts_with(SYNC_NAMESPACE) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let (_, synctoken) = synctoken.split_at(SYNC_NAMESPACE.len());
|
|
||||||
synctoken.parse::<i64>().ok()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ pub mod timestamp;
|
|||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod calendar;
|
pub mod calendar;
|
||||||
|
pub mod synctoken;
|
||||||
|
|
||||||
pub use addressbook_store::AddressbookStore;
|
pub use addressbook_store::AddressbookStore;
|
||||||
pub use calendar_store::CalendarStore;
|
pub use calendar_store::CalendarStore;
|
||||||
|
|||||||
13
crates/store/src/synctoken.rs
Normal file
13
crates/store/src/synctoken.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const SYNC_NAMESPACE: &str = "github.com/lennart-k/rustical/ns/";
|
||||||
|
|
||||||
|
pub fn format_synctoken(synctoken: i64) -> String {
|
||||||
|
format!("{}{}", SYNC_NAMESPACE, synctoken)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_synctoken(synctoken: &str) -> Option<i64> {
|
||||||
|
if !synctoken.starts_with(SYNC_NAMESPACE) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let (_, synctoken) = synctoken.split_at(SYNC_NAMESPACE.len());
|
||||||
|
synctoken.parse::<i64>().ok()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user