pub struct NameComponent {
pub typ: u64,
pub value: Bytes,
}Expand description
A single NDN name component: a (type, value) pair.
The value is a zero-copy slice of the original packet buffer.
Ordering follows the NDN Packet Format v0.3 §2.1 canonical order: TLV-TYPE first, then TLV-LENGTH (shorter is smaller), then TLV-VALUE byte-by-byte. This matches the order used by NFD and ndn-cxx.
Fields§
§typ: u64§value: BytesImplementations§
Source§impl NameComponent
impl NameComponent
pub fn new(typ: u64, value: Bytes) -> Self
pub fn generic(value: Bytes) -> Self
Sourcepub fn blake3_digest(hash: [u8; 32]) -> Self
pub fn blake3_digest(hash: [u8; 32]) -> Self
Create a BLAKE3 content-digest component (type 0x03, 32 bytes).
Experimental / NDA extension. The 32-byte BLAKE3 hash of a block’s content forms a self-certifying name component in NDA zones. The actual BLAKE3 computation must be performed by the caller.
Sourcepub fn as_blake3_digest(&self) -> Option<[u8; 32]>
pub fn as_blake3_digest(&self) -> Option<[u8; 32]>
Extract the 32-byte BLAKE3 digest value, or None if this is not a
BLAKE3_DIGEST (type 0x03) component or the value is not 32 bytes.
Sourcepub fn byte_offset(offset: u64) -> Self
pub fn byte_offset(offset: u64) -> Self
Create a ByteOffset component (type 0x34), big-endian with leading zeros stripped.
Sourcepub fn version(v: u64) -> Self
pub fn version(v: u64) -> Self
Create a Version component (type 0x36), big-endian with leading zeros stripped.
Sourcepub fn timestamp(ts: u64) -> Self
pub fn timestamp(ts: u64) -> Self
Create a Timestamp component (type 0x38), big-endian with leading zeros stripped.
Sourcepub fn sequence_num(seq: u64) -> Self
pub fn sequence_num(seq: u64) -> Self
Create a SequenceNum component (type 0x3A), big-endian with leading zeros stripped.
Sourcepub fn as_segment(&self) -> Option<u64>
pub fn as_segment(&self) -> Option<u64>
Decode a Segment component value as u64. Returns None if not type 0x32.
Sourcepub fn as_byte_offset(&self) -> Option<u64>
pub fn as_byte_offset(&self) -> Option<u64>
Decode a ByteOffset component value as u64. Returns None if not type 0x34.
Sourcepub fn as_version(&self) -> Option<u64>
pub fn as_version(&self) -> Option<u64>
Decode a Version component value as u64. Returns None if not type 0x36.
Sourcepub fn as_timestamp(&self) -> Option<u64>
pub fn as_timestamp(&self) -> Option<u64>
Decode a Timestamp component value as u64. Returns None if not type 0x38.
Sourcepub fn as_sequence_num(&self) -> Option<u64>
pub fn as_sequence_num(&self) -> Option<u64>
Decode a SequenceNum component value as u64. Returns None if not type 0x3A.
Trait Implementations§
Source§impl Clone for NameComponent
impl Clone for NameComponent
Source§fn clone(&self) -> NameComponent
fn clone(&self) -> NameComponent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NameComponent
impl Debug for NameComponent
Source§impl Hash for NameComponent
impl Hash for NameComponent
Source§impl Ord for NameComponent
impl Ord for NameComponent
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
NDN canonical component ordering (NDN Packet Format v0.3 §2.1).
Order: TLV-TYPE ascending, then TLV-LENGTH ascending (shorter is smaller), then TLV-VALUE byte-by-byte ascending.