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

Method export_snapshot

nodedb/src/control/array_sync/schema_registry.rs:186–200  ·  view source on GitHub ↗

Export the current Loro snapshot bytes for `array`, or `None` if unknown.

(&self, array: &str)

Source from the content-addressed store, hash-verified

184
185 /// Export the current Loro snapshot bytes for `array`, or `None` if unknown.
186 pub fn export_snapshot(&self, array: &str) -> crate::Result<Option<Vec<u8>>> {
187 let docs = self.docs.lock().map_err(|_| Error::Storage {
188 engine: "array_sync".into(),
189 detail: "schema_registry lock poisoned".into(),
190 })?;
191 if let Some(doc) = docs.get(array) {
192 let bytes = doc.export_snapshot().map_err(|e| Error::Storage {
193 engine: "array_sync".into(),
194 detail: format!("schema_registry export '{array}': {e}"),
195 })?;
196 Ok(Some(bytes))
197 } else {
198 Ok(None)
199 }
200 }
201
202 // ─── Internal helpers ─────────────────────────────────────────────────────
203

Callers 2

import_snapshotMethod · 0.45

Calls 2

lockMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected