NameComponent

Struct NameComponent 

Source
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: Bytes

Implementations§

Source§

impl NameComponent

Source

pub fn new(typ: u64, value: Bytes) -> Self

Source

pub fn generic(value: Bytes) -> Self

Source

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.

Source

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.

Source

pub fn keyword(value: Bytes) -> Self

Create a Keyword component (type 0x20) with opaque bytes.

Source

pub fn byte_offset(offset: u64) -> Self

Create a ByteOffset component (type 0x34), big-endian with leading zeros stripped.

Source

pub fn version(v: u64) -> Self

Create a Version component (type 0x36), big-endian with leading zeros stripped.

Source

pub fn timestamp(ts: u64) -> Self

Create a Timestamp component (type 0x38), big-endian with leading zeros stripped.

Source

pub fn sequence_num(seq: u64) -> Self

Create a SequenceNum component (type 0x3A), big-endian with leading zeros stripped.

Source

pub fn as_segment(&self) -> Option<u64>

Decode a Segment component value as u64. Returns None if not type 0x32.

Source

pub fn as_byte_offset(&self) -> Option<u64>

Decode a ByteOffset component value as u64. Returns None if not type 0x34.

Source

pub fn as_version(&self) -> Option<u64>

Decode a Version component value as u64. Returns None if not type 0x36.

Source

pub fn as_timestamp(&self) -> Option<u64>

Decode a Timestamp component value as u64. Returns None if not type 0x38.

Source

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

Source§

fn clone(&self) -> NameComponent

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 NameComponent

Source§

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

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

impl Hash for NameComponent

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

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 NameComponent

Source§

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.

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 NameComponent

Source§

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

Source§

fn partial_cmp(&self, other: &Self) -> 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 NameComponent

Source§

impl StructuralPartialEq for NameComponent

Auto Trait Implementations§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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.