Skip to main content

Path

Struct Path 

Source
pub struct Path { /* private fields */ }
Expand description

A place in a document: a root name the document kind gives, then keys and indexes.

Written as root.key[2].other; a key that is empty or holds ., [, ], ", \, whitespace or a control character is written quoted, root["a key"].

Implementations§

Source§

impl Path

Source

pub fn root(name: impl Into<String>) -> Self

The root of a document.

Source

pub fn key(&self, key: impl Into<String>) -> Self

The path one key further.

Source

pub fn index(&self, index: usize) -> Self

The path one index further.

Source

pub fn push(&mut self, segment: Segment)

Adds a segment.

Source

pub fn pop(&mut self) -> Option<Segment>

Removes and answers the last segment.

Source

pub fn join(&self, segments: impl IntoIterator<Item = Segment>) -> Self

The path with segments added.

Source

pub fn root_name(&self) -> &str

The root name.

Source

pub fn segments(&self) -> &[Segment]

The keys and indexes after the root.

Source

pub fn last(&self) -> Option<&Segment>

The last segment.

Source

pub fn last_key(&self) -> Option<&str>

The last segment when it is a key.

Source

pub fn parent(&self) -> Option<Self>

The path one step up, or None at the root.

Source

pub fn starts_with(&self, other: &Self) -> bool

Whether self is other or lies inside it (roots compared too).

Source

pub fn starred(&self) -> String

The written form with every index replaced by *, which groups one problem repeated over a list.

Source

pub fn parse(text: &str) -> Result<Self, PathError>

Reads a written path. The first name is the root; spec.body.children[2].path, project["a key"][0].

§Errors

PathError with the offset of the first character that does not fit.

Source

pub fn join_text(&self, relative: &str) -> Result<Self, PathError>

The path with a relative written path added: visual.opacity, [2].value or .visual. An empty text or . adds nothing.

§Errors

PathError with the offset in relative.

Trait Implementations§

Source§

impl Clone for Path

Source§

fn clone(&self) -> Self

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

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

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

Source§

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

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

impl Display for Path

Source§

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

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

impl Eq for Path

Source§

impl Hash for Path

Source§

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

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: &Self) -> 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: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

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

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Forget for Path

§

impl Freeze for Path

§

impl Move for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path
where RawVecInner: Send,

§

impl Sync for Path
where RawVecInner: Sync,

§

impl Unpin for Path
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path
where RawVecInner: UnwindSafe,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.