Skip to main content

Path

Struct Path 

Source
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

Source

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.

Source

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 Clone for Path

Source§

fn clone(&self) -> Path

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Path

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Path, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Path

Source§

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.

Source§

impl Eq for Path

Source§

impl FromStr for Path

Source§

type Err = PathParseError

The associated error which can be returned from parsing.
Source§

fn from_str(path: &str) -> Result<Path, <Path as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Path

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Path

Source§

fn eq(&self, other: &Path) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Path

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.