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

Function snapshot_key

nodedb/src/control/array_sync/snapshot_store.rs:33–41  ·  view source on GitHub ↗

Build the composite key: `[name_len: u8][name bytes][hlc: 18 bytes]`.

(array: &str, hlc: Hlc)

Source from the content-addressed store, hash-verified

31
32/// Build the composite key: `[name_len: u8][name bytes][hlc: 18 bytes]`.
33fn snapshot_key(array: &str, hlc: Hlc) -> Option<Vec<u8>> {
34 let name_bytes = array.as_bytes();
35 let name_len = u8::try_from(name_bytes.len()).ok()?;
36 let mut key = Vec::with_capacity(1 + name_bytes.len() + 18);
37 key.push(name_len);
38 key.extend_from_slice(name_bytes);
39 key.extend_from_slice(&hlc.to_bytes());
40 Some(key)
41}
42
43/// Build the name-prefix used for range scans: `[name_len: u8][name bytes]`.
44fn name_prefix(array: &str) -> Option<Vec<u8>> {

Callers 2

putMethod · 0.85
getMethod · 0.85

Calls 5

as_bytesMethod · 0.45
okMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected