pub struct Snapshot {
pub version: u8,
pub id: Hash,
pub version_vector: VersionVector,
pub superseded_roots: Vec<Hash>,
pub state_data: Vec<u8>,
pub created_at: u64,
pub creator: String,
pub metadata: HashMap<String, String>,
}Expand description
A snapshot of CRDT state at a specific point in causal history.
Fields§
§version: u8Format version for compatibility.
id: HashUnique identifier for this snapshot.
version_vector: VersionVectorThe version vector at the time of the snapshot. This represents the causal frontier.
superseded_roots: Vec<Hash>The CIDs of DAG nodes that this snapshot supersedes. These can be safely pruned after the snapshot is stable.
state_data: Vec<u8>The serialized CRDT state.
created_at: u64Timestamp when the snapshot was created.
creator: StringThe replica that created this snapshot.
metadata: HashMap<String, String>Optional metadata about the snapshot.
Implementations§
Source§impl Snapshot
impl Snapshot
Sourcepub fn new(
version_vector: VersionVector,
superseded_roots: Vec<Hash>,
state_data: Vec<u8>,
creator: impl Into<String>,
created_at: u64,
) -> Self
pub fn new( version_vector: VersionVector, superseded_roots: Vec<Hash>, state_data: Vec<u8>, creator: impl Into<String>, created_at: u64, ) -> Self
Create a new snapshot from serialized state.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata to the snapshot.
Sourcepub fn to_merkle_node(&self) -> Result<MerkleNode, SnapshotError>
pub fn to_merkle_node(&self) -> Result<MerkleNode, SnapshotError>
Convert this snapshot to a MerkleNode for storage in the DAG.
Sourcepub fn from_merkle_node(node: &MerkleNode) -> Result<Self, SnapshotError>
pub fn from_merkle_node(node: &MerkleNode) -> Result<Self, SnapshotError>
Deserialize a snapshot from a MerkleNode payload.
Sourcepub fn covers(&self, vv: &VersionVector) -> bool
pub fn covers(&self, vv: &VersionVector) -> bool
Check if this snapshot covers a given version vector.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Snapshot
impl<'de> Deserialize<'de> for Snapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Snapshot
impl RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl UnwindSafe for Snapshot
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