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
impl Name
pub fn from_components( components: impl IntoIterator<Item = NameComponent>, ) -> Name
pub fn components(&self) -> &[NameComponent]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn has_prefix(&self, prefix: &Name) -> bool
pub fn has_prefix(&self, prefix: &Name) -> bool
Returns true if prefix is a prefix of (or equal to) this name.
Sourcepub fn decode(value: Bytes) -> Result<Name, PacketError>
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).
Sourcepub fn append(self, value: impl AsRef<[u8]>) -> Name
pub fn append(self, value: impl AsRef<[u8]>) -> Name
Append a generic component from raw bytes.
Sourcepub fn append_component(self, comp: NameComponent) -> Name
pub fn append_component(self, comp: NameComponent) -> Name
Append an already-constructed component.
Sourcepub fn append_segment(self, seg: u64) -> Name
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).
Sourcepub fn append_version(self, v: u64) -> Name
pub fn append_version(self, v: u64) -> Name
Append a Version component (type 0x36).
Sourcepub fn append_timestamp(self, ts: u64) -> Name
pub fn append_timestamp(self, ts: u64) -> Name
Append a Timestamp component (type 0x38).
Sourcepub fn append_sequence_num(self, seq: u64) -> Name
pub fn append_sequence_num(self, seq: u64) -> Name
Append a SequenceNum component (type 0x3A).
Sourcepub fn append_byte_offset(self, off: u64) -> Name
pub fn append_byte_offset(self, off: u64) -> Name
Append a ByteOffset component (type 0x34).
Sourcepub fn append_blake3_digest(self, hash: [u8; 32]) -> Name
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.
Sourcepub fn zone_root_from_hash(hash: [u8; 32]) -> Name
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.
Sourcepub fn is_zone_root(&self) -> bool
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 FromStr for Name
impl FromStr for Name
Source§fn from_str(s: &str) -> Result<Name, <Name as FromStr>::Err>
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
type Err = PacketError
Source§impl Ord for Name
impl Ord for Name
Source§fn cmp(&self, other: &Name) -> Ordering
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) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Name
impl PartialOrd for Name
impl Eq for Name
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.