Skip to main content

Name

Struct Name 

Source
pub struct Name {
    pub components: Vec<NameComponent>,
}
Expand description

A hierarchical NDN name: an ordered sequence of NameComponents.

Names identify both Interests and the Data that satisfies them, and are usually written and read as a ndn:/a/b/c-style URI – see Name::from_str and Name::to_uri. Name implements Ord so names can be sorted and compared, by comparing their encoded bytes.

Fields§

§components: Vec<NameComponent>

The name’s components, in order from least to most specific.

Implementations§

Source§

impl Name

Source

pub const fn empty() -> Self

The name with no components, i.e. ndn:/.

Source

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

Parses a name from its URI form, e.g. /hello/world or ndn:/hello/world. The leading ndn: scheme is optional.

Source

pub fn to_uri(&self) -> Url

Renders the name back into its ndn:/a/b/c URI form.

Source

pub fn iter(&self) -> impl Iterator<Item = &NameComponent>

Iterates over the name’s components.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut NameComponent>

Iterates mutably over the name’s components.

Source

pub fn into_iter(self) -> impl Iterator<Item = NameComponent>

Consumes the name, iterating over its components by value.

Source

pub fn join<T: TryInto<Self>>(&self, other: T) -> Self
where <T as TryInto<Self>>::Error: Debug,

Appends other’s components to this name’s, returning the combined name. other can be another Name, a URI &str, or anything else that converts to a Name.

§Panics

Panics if other fails to convert into a Name, e.g. an invalid URI string.

Source

pub fn has_prefix(&self, prefix: &Name) -> bool

Returns whether prefix is a prefix of this name, component by component.

Source

pub fn remove_prefix(&mut self, prefix: &Name) -> bool

Removes prefix from the front of this name if it’s actually a prefix, returning whether anything was removed.

Trait Implementations§

Source§

impl Clone for Name

Source§

fn clone(&self) -> Name

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 Name

Source§

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

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

impl Display for Name

Source§

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

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

impl Eq for Name

Source§

impl Extend<NameComponent> for Name

Source§

fn extend<T: IntoIterator<Item = NameComponent>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<NameComponent> for Name

Source§

fn from(value: NameComponent) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<NameComponent> for Name

Source§

fn from_iter<T: IntoIterator<Item = NameComponent>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Name

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 Ord for Name

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl PartialEq for Name

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Name

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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 StructuralPartialEq for Name

Source§

impl Tlv for Name

Source§

const TYP: usize = 7usize

The assigned type number for this TLV record
Source§

fn inner_size(&self) -> usize

The size of the payload contained within this TLV Read more
Source§

fn critical() -> bool

Whether the TLV is critical, see tlv_critical
Source§

fn from_reader(reader: impl Read) -> Result<Self, TlvError>
where Self: TlvDecode,

Read a TLV from a type implementing Read
Source§

impl TlvDecode for Name

Source§

fn decode(bytes: &mut Bytes) -> Result<Self>

Decode the value from a bytes::Buf Read more
Source§

impl TlvEncode for Name

Source§

fn encode(&self) -> Bytes

Encode the value as a TLV record or part of one
Source§

fn size(&self) -> usize

The size of the encoded data in bytes
Source§

impl TryFrom<&str> for Name

Source§

type Error = NdnError

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

fn try_from(value: &str) -> Result<Name, NdnError>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Name

§

impl RefUnwindSafe for Name

§

impl Send for Name

§

impl Sync for Name

§

impl Unpin for Name

§

impl UnsafeUnpin for Name

§

impl UnwindSafe for Name

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V