Struct OrdPathBuf

Source
pub struct OrdPathBuf<E: Encoding = DefaultEncoding, const N: usize = USIZE_BYTES> { /* private fields */ }
Expand description

A data type representing an ORDPATH is stored as a continuous sequence of bytes.

Implementations§

Source§

impl<E: Encoding, const N: usize> OrdPathBuf<E, N>

Source

pub fn from_ordinals(s: &[i64], enc: E) -> Self

Encodes a slice s to return a new OrdPath with the specified encoding.

§Panics

This function might panic if the given slice contains ordinals that are out of the range the provided encoding supports, or the resulting ORDPATH exceeds the maximum supported length.

See also [OrdPath::try_from_ordinals] which will return an Error rather than panicking.

Source

pub fn from_str(s: &str, enc: E) -> Self

Parses a string s to return a new OrdPath with the specified encoding.

§Panics

This function might panic if the given string contains any value other than numbers separated by dots, or it contains numbers that are out of the range the provided encoding supports, or the resulting ORDPATH exceeds the maximum supported length.

See also [OrdPath::try_from_str] which will return an Error rather than panicking.

Source

pub fn from_bytes(s: &[u8], enc: E) -> Self

Creates an OrdPath from a byte slice s.

§Panics

This function might panic if the given slice is not a valid ORDPATH, it cannot be read by the provided encoding, or the given slice exceeds the maximum supported length.

See also [OrdPath::try_from_bytes] which will return an Error rather than panicking.

Source

pub fn try_from_ordinals(s: &[i64], enc: E) -> Result<Self, Error>

Tries to encode a slice of ordinals s and create a new OrdPath.

Source

pub fn try_from_str(s: &str, enc: E) -> Result<Self, Error>

Tries to parse a string s and create a new OrdPath.

Source

pub fn try_from_bytes(s: &[u8], enc: E) -> Result<Self, Error>

Tries to create an OrdPath from a byte slice ’s`.

Source

pub fn encoding(&self) -> &E

Returns a reference to the used encoding.

Methods from Deref<Target = OrdPath<E, N>>§

Source

pub fn encoding(&self) -> &E

Returns a reference to the used encoding.

Source

pub fn bytes(&self) -> &Bytes

Produces an iterator over the bytes of an OrdPath.

Source

pub fn ordinals(&self) -> Ordinals<&Bytes, &E>

Produces an iterator over the ordinals of an OrdPath.

Source

pub fn ancestors(&self) -> Ancestors<'_, E, N>

Produces an iterator over OrdPath ancestors.

The iterator will yield the OrdPath that is returned if the [parent] method is used one or more times. If the [parent] method returns None, the iterator will do likewise.

§Examples
let path = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
let mut ancestors = path.ancestors();
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("1.2".to_owned()));
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("1".to_owned()));
assert_eq!(ancestors.next().map(|p| p.to_string()), Some("".to_owned()));
assert_eq!(ancestors.next(), None);
Source

pub fn parent(&self) -> Option<&OrdPath<E, N>>

Returns the OrdPath without its final element, if there is one.

Source

pub fn is_ancestor_of(&self, other: &Self) -> bool
where E: PartialEq,

Returns true if self is an ancestor of other.

§Examples
let a = <OrdPathBuf>::from_ordinals(&[1, 2], DefaultEncoding);
let d = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
assert!(a.is_ancestor_of(&d));

See also OrdPath::is_descendant_of.

Source

pub fn is_descendant_of(&self, other: &Self) -> bool
where E: PartialEq,

Returns true if self is an descendant of other.

§Examples
let a = <OrdPathBuf>::from_ordinals(&[1, 2], DefaultEncoding);
let d = <OrdPathBuf>::from_ordinals(&[1, 2, 3], DefaultEncoding);
assert!(d.is_descendant_of(&a));

See also OrdPath::is_ancestor_of.

Trait Implementations§

Source§

impl<E: Encoding, const N: usize> AsRef<[u8]> for OrdPathBuf<E, N>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<E: Encoding, const N: usize> Borrow<OrdPath<E, N>> for OrdPathBuf<E, N>

Source§

fn borrow(&self) -> &OrdPath<E, N>

Immutably borrows from an owned value. Read more
Source§

impl<E, const N: usize> Clone for OrdPathBuf<E, N>
where E: Clone + Encoding,

Source§

fn clone(&self) -> Self

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<E: Encoding, const N: usize> Debug for OrdPathBuf<E, N>

Source§

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

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

impl<E: Encoding, const N: usize> Deref for OrdPathBuf<E, N>

Source§

type Target = OrdPath<E, N>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<E: Encoding, const N: usize> Display for OrdPathBuf<E, N>

Source§

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

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

impl<E: Encoding + Default, const N: usize> FromStr for OrdPathBuf<E, N>

Source§

type Err = Error

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

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl<E: Encoding, const N: usize> Hash for OrdPathBuf<E, N>

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<E, const N: usize> PartialEq for OrdPathBuf<E, N>
where E: PartialEq + Encoding,

Source§

fn eq(&self, other: &Self) -> 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<E, const N: usize> PartialOrd for OrdPathBuf<E, N>
where E: PartialEq + Encoding,

Source§

fn partial_cmp(&self, other: &Self) -> 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

Auto Trait Implementations§

§

impl<E, const N: usize> Freeze for OrdPathBuf<E, N>
where E: Freeze,

§

impl<E, const N: usize> RefUnwindSafe for OrdPathBuf<E, N>
where E: RefUnwindSafe,

§

impl<E = DefaultEncoding, const N: usize = USIZE_BYTES> !Send for OrdPathBuf<E, N>

§

impl<E = DefaultEncoding, const N: usize = USIZE_BYTES> !Sync for OrdPathBuf<E, N>

§

impl<E, const N: usize> Unpin for OrdPathBuf<E, N>
where E: Unpin,

§

impl<E, const N: usize> UnwindSafe for OrdPathBuf<E, N>
where E: 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.