MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / export_snapshot

Method export_snapshot

nodedb-array/src/sync/schema_crdt.rs:105–115  ·  view source on GitHub ↗

Export the full Loro snapshot as an enveloped byte buffer. The returned bytes have the format: `[LORO_FORMAT_VERSION: u8][loro snapshot bytes…]` Pass the result to [`SchemaDoc::import_snapshot`] (or [`SchemaDoc::import_snapshot_replicated`]) on another replica to converge schema state.

(&self)

Source from the content-addressed store, hash-verified

103 /// [`SchemaDoc::import_snapshot_replicated`]) on another replica to
104 /// converge schema state.
105 pub fn export_snapshot(&self) -> ArrayResult<Vec<u8>> {
106 let loro_bytes = self.doc.export(loro::ExportMode::Snapshot).map_err(|e| {
107 ArrayError::SegmentCorruption {
108 detail: format!("loro snapshot export failed: {e}"),
109 }
110 })?;
111 let mut envelope = Vec::with_capacity(1 + loro_bytes.len());
112 envelope.push(LORO_FORMAT_VERSION);
113 envelope.extend_from_slice(&loro_bytes);
114 Ok(envelope)
115 }
116
117 /// Import a Loro snapshot from a remote replica.
118 ///

Calls 3

exportMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45