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

Function ack_key

nodedb/src/control/array_sync/ack_registry.rs:30–38  ·  view source on GitHub ↗

Build the key: `[name_len: u8][name bytes][replica_id: u64 BE]`.

(array: &str, replica_id: u64)

Source from the content-addressed store, hash-verified

28
29/// Build the key: `[name_len: u8][name bytes][replica_id: u64 BE]`.
30fn ack_key(array: &str, replica_id: u64) -> Option<Vec<u8>> {
31 let name_bytes = array.as_bytes();
32 let name_len = u8::try_from(name_bytes.len()).ok()?;
33 let mut key = Vec::with_capacity(1 + name_bytes.len() + 8);
34 key.push(name_len);
35 key.extend_from_slice(name_bytes);
36 key.extend_from_slice(&replica_id.to_be_bytes());
37 Some(key)
38}
39
40/// Parse the array name from the head of a composite key.
41///

Callers 1

recordMethod · 0.85

Calls 4

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

Tested by

no test coverage detected