mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-22 18:39:31 +00:00
put synctoken into common module
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::synctoken::format_synctoken;
|
||||
use chrono::NaiveDateTime;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -15,18 +16,3 @@ impl Addressbook {
|
||||
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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user