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>, ) -> Self
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<Self, PacketError>
pub fn decode(value: Bytes) -> Result<Self, 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]>) -> Self
pub fn append(self, value: impl AsRef<[u8]>) -> Self
Append a generic component from raw bytes.
Sourcepub fn append_component(self, comp: NameComponent) -> Self
pub fn append_component(self, comp: NameComponent) -> Self
Append an already-constructed component.
Sourcepub fn append_segment(self, seg: u64) -> Self
pub fn append_segment(self, seg: u64) -> Self
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) -> Self
pub fn append_version(self, v: u64) -> Self
Append a Version component (type 0x36).
Sourcepub fn append_timestamp(self, ts: u64) -> Self
pub fn append_timestamp(self, ts: u64) -> Self
Append a Timestamp component (type 0x38).
Sourcepub fn append_sequence_num(self, seq: u64) -> Self
pub fn append_sequence_num(self, seq: u64) -> Self
Append a SequenceNum component (type 0x3A).
Sourcepub fn append_byte_offset(self, off: u64) -> Self
pub fn append_byte_offset(self, off: u64) -> Self
Append a ByteOffset component (type 0x34).
Sourcepub fn append_blake3_digest(self, hash: [u8; 32]) -> Self
pub fn append_blake3_digest(self, hash: [u8; 32]) -> Self
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]) -> Self
pub fn zone_root_from_hash(hash: [u8; 32]) -> Self
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<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::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: &Self) -> Ordering
fn cmp(&self, other: &Self) -> 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).