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

Function read_str

nodedb-query/src/msgpack_scan/reader.rs:271–275  ·  view source on GitHub ↗

Read a string slice from the value at `offset`. Zero-copy — borrows directly from the input buffer. Returns `None` for non-string types or invalid UTF-8.

(buf: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

269/// directly from the input buffer. Returns `None` for non-string types
270/// or invalid UTF-8.
271pub fn read_str(buf: &[u8], offset: usize) -> Option<&str> {
272 let (start, len) = str_bounds(buf, offset)?;
273 let bytes = buf.get(start..start + len)?;
274 str::from_utf8(bytes).ok()
275}
276
277/// Read a string slice at `*off`, advancing `*off` past it. Zero-copy.
278/// Returns `None` for non-string types, invalid UTF-8, or truncated input.

Callers 15

eval_opFunction · 0.70
find_field_by_suffixFunction · 0.70
str_matchFunction · 0.70
extract_strFunction · 0.70
append_field_valueFunction · 0.70
append_field_value_rangeFunction · 0.70
extract_str_valFunction · 0.70
merge_fieldsFunction · 0.70
roundtrip_mapFunction · 0.70
read_valueFunction · 0.70

Calls 3

str_boundsFunction · 0.85
getMethod · 0.45
okMethod · 0.45