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

Function name_prefix

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

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

(array: &str)

Source from the content-addressed store, hash-verified

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

Callers 2

op_keyFunction · 0.70
scan_rangeMethod · 0.70

Calls 4

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

Tested by

no test coverage detected