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

Function parse_expiry_key

nodedb/src/engine/kv/engine_helpers.rs:24–32  ·  view source on GitHub ↗

Parse a composite expiry key back into (tenant_id, collection, key_bytes).

(composite: &[u8])

Source from the content-addressed store, hash-verified

22
23/// Parse a composite expiry key back into (tenant_id, collection, key_bytes).
24pub(super) fn parse_expiry_key(composite: &[u8]) -> Option<(u64, String, Vec<u8>)> {
25 let null_pos = composite.iter().position(|&b| b == 0)?;
26 let prefix = std::str::from_utf8(&composite[..null_pos]).ok()?;
27 let colon_pos = prefix.find(':')?;
28 let tenant_id: u64 = prefix[..colon_pos].parse().ok()?;
29 let collection = prefix[colon_pos + 1..].to_string();
30 let key = composite[null_pos + 1..].to_vec();
31 Some((tenant_id, collection, key))
32}
33
34// ---------------------------------------------------------------------------
35// Field extraction from MessagePack values (for secondary index maintenance)

Callers 1

tick_expiryMethod · 0.85

Calls 6

to_stringMethod · 0.80
iterMethod · 0.45
okMethod · 0.45
findMethod · 0.45
parseMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected