MCPcopy Create free account
hub / github.com/calfonso/rusternetes / parse_path

Function parse_path

crates/api-server/src/patch.rs:608–623  ·  view source on GitHub ↗

Parse a JSON pointer path into parts

(path: &str)

Source from the content-addressed store, hash-verified

606
607/// Parse a JSON pointer path into parts
608fn parse_path(path: &str) -> Result<Vec<String>, PatchError> {
609 if !path.starts_with('/') {
610 return Err(PatchError::InvalidPatch(format!(
611 "Path must start with '/': {}",
612 path
613 )));
614 }
615
616 Ok(path[1..]
617 .split('/')
618 .map(|part| {
619 // Unescape ~1 -> / and ~0 -> ~
620 part.replace("~1", "/").replace("~0", "~")
621 })
622 .collect())
623}
624
625/// Split a path into parent path and final key
626fn split_path(path: &str) -> Result<(&str, &str), PatchError> {

Callers 2

get_valueFunction · 0.85
get_mut_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected