pub struct Path(/* private fields */);Expand description
A parsed, validated context path — the canonical IR for the flow.ir
$.a.b / RFC 9535-style bracket path syntax. The full syntax and
rejection rules are documented on Path::read / Path::write and
the FromStr implementation below.
Illegal path syntax cannot be represented by this type: the only way to
construct a Path is FromStr::from_str (equivalently str::parse)
or Deserialize, both of which reject malformed input up front. Once
you hold a Path, Path::read / Path::write never re-derive or
re-validate the segment list.
Implementations§
Source§impl Path
impl Path
Sourcepub fn read<'a>(&self, ctx: &'a Value) -> Result<&'a Value, EvalError>
pub fn read<'a>(&self, ctx: &'a Value) -> Result<&'a Value, EvalError>
Read the value this path resolves to inside ctx.
The root path ($) resolves to ctx itself. A missing key along the
way raises EvalError::PathNotFound — malformed syntax is
rejected earlier, at parse time, so read can never raise
EvalError::InvalidPath.
Sourcepub fn write(&self, ctx: &mut Value, value: Value) -> Result<(), EvalError>
pub fn write(&self, ctx: &mut Value, value: Value) -> Result<(), EvalError>
Write value at the location this path resolves to inside ctx,
mutating ctx in place.
The root path ($) replaces ctx wholesale. Missing intermediate
objects along the way are created automatically (a null — or
altogether absent — intermediate promotes to an empty object, same
as before this type existed). If an intermediate segment already
holds a concrete non-object value (a string, number, bool, or
array), the write is rejected with EvalError::TypeError instead
of silently clobbering it; ctx is left byte-for-byte unmodified in
that case (a rejected write never partially applies, because every
intermediate object promotion this method performs only ever touches
a freshly-created — previously null/absent — subtree, which by
construction cannot itself contain a pre-existing conflicting value
further down).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for Path
impl Display for Path
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Canonical string form: $ + .key for each identifier-safe segment,
["key"] bracket form otherwise. Path::from_str(path.to_string())
always re-parses to an equal Path (round-trip law) — the canonical
form may normalize the representation (e.g. a segment reachable
only via dot form on the way in is still rendered via dot form; a
segment that required bracket form on the way in is rendered via
bracket form) without changing the parsed segment list.
impl Eq for Path
Source§impl Serialize for Path
impl Serialize for Path
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for Path
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more