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) -> NameComponent
pub fn generic(value: Bytes) -> NameComponent
Sourcepub fn blake3_digest(hash: [u8; 32]) -> NameComponent
pub fn blake3_digest(hash: [u8; 32]) -> NameComponent
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 keyword(value: Bytes) -> NameComponent
pub fn keyword(value: Bytes) -> NameComponent
Create a Keyword component (type 0x20) with opaque bytes.
Sourcepub fn byte_offset(offset: u64) -> NameComponent
pub fn byte_offset(offset: u64) -> NameComponent
Create a ByteOffset component (type 0x34), big-endian with leading zeros stripped.
Sourcepub fn version(v: u64) -> NameComponent
pub fn version(v: u64) -> NameComponent
Create a Version component (type 0x36), big-endian with leading zeros stripped.
Sourcepub fn timestamp(ts: u64) -> NameComponent
pub fn timestamp(ts: u64) -> NameComponent
Create a Timestamp component (type 0x38), big-endian with leading zeros stripped.
Sourcepub fn sequence_num(seq: u64) -> NameComponent
pub fn sequence_num(seq: u64) -> NameComponent
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: &NameComponent) -> Ordering
fn cmp(&self, other: &NameComponent) -> 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.
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NameComponent
impl PartialEq for NameComponent
Source§impl PartialOrd for NameComponent
impl PartialOrd for NameComponent
impl Eq for NameComponent
impl StructuralPartialEq for NameComponent
Auto Trait Implementations§
impl !Freeze for NameComponent
impl RefUnwindSafe for NameComponent
impl Send for NameComponent
impl Sync for NameComponent
impl Unpin for NameComponent
impl UnwindSafe for NameComponent
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.