Name

Struct Name 

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

An NDN name: an ordered sequence of name components.

Components are stored in a SmallVec with inline capacity for 8 elements, covering typical 4–8 component names without heap allocation.

Ordering follows the NDN Packet Format v0.3 §2.1 canonical order, component by component using NameComponent’s Ord impl.

Implementations§

Source§

impl Name

Source

pub fn root() -> Name

The root (empty) name /.

Source

pub fn from_components( components: impl IntoIterator<Item = NameComponent>, ) -> Name

Source

pub fn components(&self) -> &[NameComponent]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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

Returns true if prefix is a prefix of (or equal to) this name.

Source

pub fn decode(value: Bytes) -> Result<Name, PacketError>

Decode a Name TLV from reader. The reader must be positioned at the start of the Name value (after the outer type+length have been consumed).

Source

pub fn append(self, value: impl AsRef<[u8]>) -> Name

Append a generic component from raw bytes.

Source

pub fn append_component(self, comp: NameComponent) -> Name

Append an already-constructed component.

Source

pub fn append_segment(self, seg: u64) -> Name

Append a segment number component (type 0x32, big-endian encoding with leading zeros stripped per NDN naming conventions).

Source

pub fn append_version(self, v: u64) -> Name

Append a Version component (type 0x36).

Source

pub fn append_timestamp(self, ts: u64) -> Name

Append a Timestamp component (type 0x38).

Source

pub fn append_sequence_num(self, seq: u64) -> Name

Append a SequenceNum component (type 0x3A).

Source

pub fn append_byte_offset(self, off: u64) -> Name

Append a ByteOffset component (type 0x34).

Source

pub fn append_blake3_digest(self, hash: [u8; 32]) -> Name

Append a BLAKE3 digest component (type 0x03, 32 bytes).

Experimental / NDA extension. See NameComponent::blake3_digest.

Source

pub fn zone_root_from_hash(hash: [u8; 32]) -> Name

Build a single-component zone-root name from a pre-computed 32-byte hash.

The hash should be the BLAKE3 digest of a public key (or any 32-byte identifier). This is the low-level constructor; use ndn_security::ZoneKey::zone_root_name() for the full API that computes the hash from a public key.

Experimental / NDA extension — BLAKE3 component type (0x03) is not yet in the NDN Packet Format specification.

Source

pub fn is_zone_root(&self) -> bool

Returns true if this name is a single BLAKE3-digest component (a zone root).

Trait Implementations§

Source§

impl Clone for Name

Source§

fn clone(&self) -> Name

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

Source§

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

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

impl Display for Name

Source§

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

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

impl From<&str> for Name

Allow &str and String to convert into Name for builder ergonomics.

Source§

fn from(s: &str) -> Name

Converts to this type from the input type.
Source§

impl From<String> for Name

Source§

fn from(s: String) -> Name

Converts to this type from the input type.
Source§

impl FromStr for Name

Source§

fn from_str(s: &str) -> Result<Name, <Name as FromStr>::Err>

Parse an NDN URI string into a Name.

Handles percent-decoding to roundtrip with Display.

let name: Name = "/edu/ucla/data".parse().unwrap();
assert_eq!(name.to_string(), "/edu/ucla/data");
Source§

type Err = PacketError

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

impl Hash for Name

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

Source§

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

NDN canonical name ordering (NDN Packet Format v0.3 §2.1).

Names are compared component by component from left to right. If all shared components are equal, the shorter name is smaller (prefix ordering).

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

Source§

fn eq(&self, other: &Name) -> 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 PartialOrd for Name

Source§

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

Source§

impl StructuralPartialEq for Name

Auto Trait Implementations§

§

impl !Freeze for Name

§

impl RefUnwindSafe for Name

§

impl Send for Name

§

impl Sync for Name

§

impl Unpin 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<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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more