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

Function unsanitize_key

nodedb/src/data/executor/spatial_checkpoint.rs:184–193  ·  view source on GitHub ↗

Reverse sanitize: restore ':' separators (best-effort). Keys are "{tid}:{collection}:{field}" → sanitized as "{tid}_{collection}_{field}". Only the first two `_` are replaced since `tid` is numeric (no underscores).

(sanitized: &str)

Source from the content-addressed store, hash-verified

182/// Keys are "{tid}:{collection}:{field}" → sanitized as "{tid}_{collection}_{field}".
183/// Only the first two `_` are replaced since `tid` is numeric (no underscores).
184fn unsanitize_key(sanitized: &str) -> String {
185 let mut result = sanitized.to_string();
186 if let Some(pos) = result.find('_') {
187 result.replace_range(pos..pos + 1, ":");
188 if let Some(pos2) = result[pos + 1..].find('_') {
189 result.replace_range(pos + 1 + pos2..pos + 1 + pos2 + 1, ":");
190 }
191 }
192 result
193}
194
195/// Parse a key string of the form "{tid}:{collection}:{field}" into a tuple.
196/// Returns `None` if the string doesn't have at least two ':' separators.

Callers 1

Calls 2

to_stringMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected