pub struct PersistedSyncState {
pub state_bytes: Vec<u8>,
pub peer_id_hex: String,
pub doc_key: String,
pub saved_at: u64,
pub sync_count: u64,
}Expand description
Serializable wrapper for automerge::sync::State
The Automerge SyncState isn’t directly serializable, so we store the encoded bytes along with metadata.
Fields§
§state_bytes: Vec<u8>Encoded sync state bytes
peer_id_hex: StringPeer ID (hex encoded for serialization)
doc_key: StringDocument key
saved_at: u64Timestamp when state was saved
sync_count: u64Number of syncs completed
Implementations§
Source§impl PersistedSyncState
impl PersistedSyncState
Sourcepub fn from_sync_state(
state: &State,
peer_id: &PublicKey,
doc_key: &str,
sync_count: u64,
) -> PersistedSyncState
pub fn from_sync_state( state: &State, peer_id: &PublicKey, doc_key: &str, sync_count: u64, ) -> PersistedSyncState
Create from SyncState and metadata
Sourcepub fn to_sync_state(&self) -> Result<State, Error>
pub fn to_sync_state(&self) -> Result<State, Error>
Restore SyncState from persisted data
Trait Implementations§
Source§impl Clone for PersistedSyncState
impl Clone for PersistedSyncState
Source§fn clone(&self) -> PersistedSyncState
fn clone(&self) -> PersistedSyncState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PersistedSyncState
impl Debug for PersistedSyncState
Source§impl<'de> Deserialize<'de> for PersistedSyncState
impl<'de> Deserialize<'de> for PersistedSyncState
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PersistedSyncState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PersistedSyncState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for PersistedSyncState
impl Serialize for PersistedSyncState
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for PersistedSyncState
impl RefUnwindSafe for PersistedSyncState
impl Send for PersistedSyncState
impl Sync for PersistedSyncState
impl Unpin for PersistedSyncState
impl UnsafeUnpin for PersistedSyncState
impl UnwindSafe for PersistedSyncState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more