mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
put synctoken into common module
This commit is contained in:
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