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

Function name_prefix

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

Build the name-prefix used for range scans: `[name_len: u8][name bytes]`.

(array: &str)

Source from the content-addressed store, hash-verified

42
43/// Build the name-prefix used for range scans: `[name_len: u8][name bytes]`.
44fn name_prefix(array: &str) -> Option<Vec<u8>> {
45 let name_bytes = array.as_bytes();
46 let name_len = u8::try_from(name_bytes.len()).ok()?;
47 let mut prefix = Vec::with_capacity(1 + name_bytes.len());
48 prefix.push(name_len);
49 prefix.extend_from_slice(name_bytes);
50 Some(prefix)
51}
52
53/// Parse the HLC from the tail of a composite key given the prefix length.
54fn hlc_from_key(key: &[u8], prefix_len: usize) -> Option<Hlc> {

Callers 2

latest_for_arrayMethod · 0.70
delete_older_thanMethod · 0.70

Calls 4

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

Tested by

no test coverage detected