Skip to main content

Path

Struct Path 

Source
pub struct Path<'a>(/* private fields */);
Expand description

A hierarchical identifier, such as a::b::c.

Paths have some logic for determining whether one path is a child of another but don’t handle relative/absolute paths or globs.

Implementations§

Source§

impl Path<'static>

Source

pub fn new(path: &'static str) -> Result<Path<'static>, InvalidPathError>

Create a path from a raw value.

This method will fail if the path is malformed. A valid path consists of one or more identifiers separated by ::s. like a::b::c. See the is_valid_path function for more details.

Source

pub const fn new_raw(path: &'static str) -> Path<'static>

Create a path from a raw value without checking its validity.

This method is not unsafe. There are no memory safety properties tied to the validity of paths. Code that uses path segments may panic or produce unexpected results if given an invalid path.

Source§

impl<'a> Path<'a>

Source

pub fn new_ref(path: &'a str) -> Result<Path<'a>, InvalidPathError>

Create a path from a raw borrowed value.

The Path::new method should be preferred where possible.

This method will fail if the path is malformed. A valid path consists of one or more identifiers separated by ::s. like a::b::c. See the is_valid_path function for more details.

Source

pub const fn new_ref_raw(path: &'a str) -> Path<'a>

Create a path from a raw borrowed value without checking its validity.

The Path::new_raw method should be preferred where possible.

This method is not unsafe. There are no memory safety properties tied to the validity of paths. Code that uses path segments may panic or produce unexpected results if given an invalid path.

Source

pub fn new_str(path: Str<'a>) -> Result<Path<'a>, InvalidPathError>

Create a path from a raw Str value.

This method will fail if the path is malformed. A valid path consists of one or more identifiers separated by ::s. like a::b::c. See the is_valid_path function for more details.

Source

pub const fn new_str_raw(path: Str<'a>) -> Path<'a>

Create a path from a raw Str value without checking its validity.

This method is not unsafe. There are no memory safety properties tied to the validity of paths. Code that uses path segments may panic or produce unexpected results if given an invalid path.

Source

pub fn by_ref<'b>(&'b self) -> Path<'b>

Get a path, borrowing data from this one.

Source

pub fn segments(&self) -> Segments<'_>

Iterate over the segments of the path.

The behavior of this method on invalid paths is undefined.

Source

pub fn is_child_of<'b>(&self, other: &Path<'b>) -> bool

Whether this path is a child of other.

The path a is a child of the path b if b is a prefix of a up to a path segment. The path a::b is a child of a. The path c::a::b is not a child of a. The path aa::b is not a child of a.

This method is reflexive. A path is considered a child of itself.

The behavior of this method on invalid paths is undefined.

Source§

impl Path<'static>

Source

pub fn new_owned( path: impl Into<Box<str>>, ) -> Result<Path<'static>, InvalidPathError>

Create a path from an owned raw value.

This method will fail if the path is malformed. A valid path consists of one or more identifiers separated by ::s. like a::b::c. See the is_valid_path function for more details.

Source

pub fn new_owned_raw(path: impl Into<Box<str>>) -> Path<'static>

Create a path from an owned raw value without checking its validity.

This method is not unsafe. There are no memory safety properties tied to the validity of paths. Code that uses path segments may panic or produce unexpected results if given an invalid path.

Source§

impl<'a> Path<'a>

Source

pub fn new_cow_ref(path: Cow<'a, str>) -> Result<Path<'a>, InvalidPathError>

Create a path from a potentially owned raw value.

If the value is Cow::Borrowed then this method will defer to Path::new_ref. If the value is Cow::Owned then this method will defer to Path::new_owned.

This method will fail if the path is malformed. A valid path consists of one or more identifiers separated by ::s. like a::b::c. See the is_valid_path function for more details.

Source

pub fn new_cow_ref_raw(path: Cow<'a, str>) -> Path<'a>

Create a path from a potentially owned raw value without checking its validity.

If the value is Cow::Borrowed then this method will defer to Path::new_ref_raw. If the value is Cow::Owned then this method will defer to Path::new_owned_raw.

This method is not unsafe. There are no memory safety properties tied to the validity of paths. Code that uses path segments may panic or produce unexpected results if given an invalid path.

Source

pub fn to_owned(&self) -> Path<'static>

Get a new path, taking an owned copy of the data in this one.

Source

pub fn to_cow(&self) -> Cow<'static, str>

Get the underlying value as a potentially owned string.

If the string contains a contiguous 'static value then this method will return Cow::Borrowed. Otherwise it will return Cow::Owned.

Source

pub fn append<'b>(self, other: impl Into<Path<'b>>) -> Path<'a>

Append other to self with a separator in-between.

Trait Implementations§

Source§

impl<'a> Clone for Path<'a>

Source§

fn clone(&self) -> Path<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Path<'a>

Source§

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

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

impl<'a> Display for Path<'a>

Source§

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

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

impl<'a, 'b> From<&'a Path<'b>> for Path<'a>

Source§

fn from(value: &'a Path<'b>) -> Path<'a>

Converts to this type from the input type.
Source§

impl<'a> FromValue<'a> for Path<'a>

Source§

fn from_value(value: Value<'a>) -> Option<Path<'a>>

Perform the conversion.
Source§

impl<'a> Hash for Path<'a>

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<'a> Ord for Path<'a>

Source§

fn cmp(&self, other: &Path<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a, 'b, 'c> PartialEq<&'c Path<'b>> for Path<'a>

Source§

fn eq(&self, other: &&'c Path<'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<&'b str> for Path<'a>

Source§

fn eq(&self, other: &&'b str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<Path<'a>> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Path<'b>> for Path<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Path<'b>> for Str<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b, 'c> PartialEq<Path<'c>> for &'b Path<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Str<'b>> for Path<'a>

Source§

fn eq(&self, other: &Str<'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<str> for Path<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd for Path<'a>

Source§

fn partial_cmp(&self, other: &Path<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Serialize for Path<'a>

Available on crate feature serde only.
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<'a> ToValue for Path<'a>

Source§

fn to_value(&self) -> Value<'_>

Perform the conversion.
Source§

impl<'a> Value for Path<'a>

Available on crate feature sval only.
Source§

fn stream<'sval, S>(&'sval self, stream: &mut S) -> Result<(), Error>
where S: Stream<'sval> + ?Sized,

Stream this value through a Stream.
Source§

fn tag(&self) -> Option<Tag>

Get the tag of this value, if there is one.
Source§

fn to_bool(&self) -> Option<bool>

Try convert this value into a boolean.
Source§

fn to_f32(&self) -> Option<f32>

Try convert this value into a 32bit binary floating point number.
Source§

fn to_f64(&self) -> Option<f64>

Try convert this value into a 64bit binary floating point number.
Source§

fn to_i8(&self) -> Option<i8>

Try convert this value into a signed 8bit integer.
Source§

fn to_i16(&self) -> Option<i16>

Try convert this value into a signed 16bit integer.
Source§

fn to_i32(&self) -> Option<i32>

Try convert this value into a signed 32bit integer.
Source§

fn to_i64(&self) -> Option<i64>

Try convert this value into a signed 64bit integer.
Source§

fn to_i128(&self) -> Option<i128>

Try convert this value into a signed 128bit integer.
Source§

fn to_u8(&self) -> Option<u8>

Try convert this value into an unsigned 8bit integer.
Source§

fn to_u16(&self) -> Option<u16>

Try convert this value into an unsigned 16bit integer.
Source§

fn to_u32(&self) -> Option<u32>

Try convert this value into an unsigned 32bit integer.
Source§

fn to_u64(&self) -> Option<u64>

Try convert this value into an unsigned 64bit integer.
Source§

fn to_u128(&self) -> Option<u128>

Try convert this value into an unsigned 128bit integer.
Source§

fn to_text(&self) -> Option<&str>

Try convert this value into a text string.
Source§

fn to_binary(&self) -> Option<&[u8]>

Try convert this value into a bitstring.
Source§

impl<'a> ValueRef<'a> for Path<'a>

Available on crate feature sval only.
Source§

fn stream_ref<S>(&self, stream: &mut S) -> Result<(), Error>
where S: Stream<'a> + ?Sized,

Stream this value through a Stream.
Source§

impl<'a> Eq for Path<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Path<'a>

§

impl<'a> RefUnwindSafe for Path<'a>

§

impl<'a> Send for Path<'a>

§

impl<'a> Sync for Path<'a>

§

impl<'a> Unpin for Path<'a>

§

impl<'a> UnwindSafe for Path<'a>

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

impl<T> Value for T
where T: Value,