pub struct PathLeaf<V> { /* private fields */ }Expand description
A leaf value addressed by a parsed path.
FromStr for PathLeaf<String> splits key.path=value, parses the LHS
as a RefPath, and stores the RHS as-is. The serde_json::Value impl
parses that RHS as JSON, falling back to a string:
port=8080 is a number, name=foo is a string.
The grammar accepts bracket steps — a[0]=1 parses — because it is the
one spelling references also use. Whether such a path may write is
RefPath::try_into_keys’ question, asked at conversion time.
Display of a typed leaf is canonical — path, =, compact JSON of the
leaf — so name=foo displays as name="foo". FromStr ∘ Display
preserves path and leaf, not the original spelling. PathLeaf<String>
displays the raw RHS.
Implementations§
Source§impl<V> PathLeaf<V>
impl<V> PathLeaf<V>
Sourcepub fn new(path: Vec<String>, leaf: V) -> Result<Self, PathError>
pub fn new(path: Vec<String>, leaf: V) -> Result<Self, PathError>
Build from path segments and a leaf. Rejects an empty path or any empty segment.
Sourcepub fn path(&self) -> &[Seg]
pub fn path(&self) -> &[Seg]
The path as steps. May hold Index steps from the
grammar — consumers that write run
try_into_keys.
Source§impl PathLeaf<String>
impl PathLeaf<String>
Sourcepub fn validate_keys(&self) -> Result<(), PathError>
pub fn validate_keys(&self) -> Result<(), PathError>
Validate this writer’s path before reading inputs or selecting a format.
Sourcepub fn into_layer<V: ConfigFormat>(self) -> Result<V, PathError>
pub fn into_layer<V: ConfigFormat>(self) -> Result<V, PathError>
Type the RHS in the native format and expand it into a nested object.