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

Method persist

nodedb/src/control/array_sync/schema_registry.rs:204–235  ·  view source on GitHub ↗
(&self, array: &str, schema_hlc: Hlc, loro_snapshot: Vec<u8>)

Source from the content-addressed store, hash-verified

202 // ─── Internal helpers ─────────────────────────────────────────────────────
203
204 fn persist(&self, array: &str, schema_hlc: Hlc, loro_snapshot: Vec<u8>) -> crate::Result<()> {
205 let persisted = PersistedSchema {
206 replica_id: self.replica_id.as_u64(),
207 schema_hlc_bytes: schema_hlc.to_bytes().to_vec(),
208 loro_snapshot,
209 };
210 let bytes = zerompk::to_msgpack_vec(&persisted).map_err(|e| Error::Storage {
211 engine: "array_sync".into(),
212 detail: format!("schema_registry persist encode '{array}': {e}"),
213 })?;
214
215 let txn = self.db.begin_write().map_err(|e| Error::Storage {
216 engine: "array_sync".into(),
217 detail: format!("schema_registry persist begin_write '{array}': {e}"),
218 })?;
219 {
220 let mut table = txn.open_table(SCHEMA_DOCS).map_err(|e| Error::Storage {
221 engine: "array_sync".into(),
222 detail: format!("schema_registry persist open_table '{array}': {e}"),
223 })?;
224 table
225 .insert(array.as_bytes(), bytes.as_slice())
226 .map_err(|e| Error::Storage {
227 engine: "array_sync".into(),
228 detail: format!("schema_registry persist insert '{array}': {e}"),
229 })?;
230 }
231 txn.commit().map_err(|e| Error::Storage {
232 engine: "array_sync".into(),
233 detail: format!("schema_registry persist commit '{array}': {e}"),
234 })
235 }
236
237 fn load_all(
238 db: &Database,

Callers 2

import_snapshotMethod · 0.45

Calls 8

begin_writeMethod · 0.80
as_u64Method · 0.45
to_vecMethod · 0.45
to_bytesMethod · 0.45
insertMethod · 0.45
as_bytesMethod · 0.45
as_sliceMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected