Skip to main content

Sndu

Struct Sndu 

Source
pub struct Sndu<'a> {
    pub dest_address: Option<[u8; 6]>,
    pub payload: PayloadChain<'a>,
}
Expand description

A parsed/owned SubNetwork Data Unit (RFC 4326 §4).

Holds typed header fields plus a borrowed view of the PDU. Length and the CRC are not stored: both are recomputed on serialize, so the round-trip is driven entirely from the typed fields (no raw passthrough).

The base-header Type field is derived from the payload chain (via PayloadChain::base_type) and is not stored as a separate field — the chain is the single source of truth so the two can never diverge. Use Sndu::type_field to read it.

Fields§

§dest_address: Option<[u8; 6]>

The 6-byte Receiver Destination NPA address (§4.5), present iff D = 0. D is derived from Some/None: D = 0Some.

§payload: PayloadChain<'a>

Decoded extension-header chain + PDU (§5). The base-header Type field is derived from the chain’s base_type() on serialize.

Implementations§

Source§

impl<'a> Sndu<'a>

Source

pub fn new( type_field: TypeField, dest_address: Option<[u8; 6]>, pdu: &'a [u8], ) -> Self

Construct an SNDU from a Type field, optional NPA address, and an opaque PDU (no extension headers).

Source

pub fn type_field(&self) -> TypeField

The base-header Type field (§4.4): derived from the payload chain’s PayloadChain::base_type. This is the value that appears on the wire at bytes [2..4] of the SNDU.

Source

pub fn d_bit(&self) -> bool

The D bit value: 1 when no Destination Address is present.

Source

pub fn pdu(&self) -> &'a [u8]

The opaque PDU bytes (after any extension-header chain).

Source

pub fn length_field(&self) -> usize

The Length field as it appears on the wire: bytes counted from the byte after the Type field, up to and including the CRC (§4.2). = NPA (if D=0) + extension-chain content + PDU + CRC.

Source

pub fn serialized_len(&self) -> usize

Total serialized size in bytes (base header + everything the Length field counts).

Source

pub fn parse(data: &'a [u8]) -> Result<Self>

Parse an SNDU from the start of data. Requires the full SNDU (header..CRC) to be present; trailing bytes are ignored. Validates the CRC-32 trailer against a recomputed value (§4.6).

Source

pub fn serialize_into(&self, out: &mut [u8]) -> Result<usize>

Serialize the SNDU into out, recomputing Length and the CRC-32 from the typed fields. Returns the number of bytes written.

Trait Implementations§

Source§

impl<'a> Clone for Sndu<'a>

Source§

fn clone(&self) -> Sndu<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Sndu<'a>

Source§

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

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

impl<'a> Eq for Sndu<'a>

Source§

impl<'a> PartialEq for Sndu<'a>

Source§

fn eq(&self, other: &Sndu<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<'a> Serialize for Sndu<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for Sndu<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Sndu<'a>

§

impl<'a> RefUnwindSafe for Sndu<'a>

§

impl<'a> Send for Sndu<'a>

§

impl<'a> Sync for Sndu<'a>

§

impl<'a> Unpin for Sndu<'a>

§

impl<'a> UnsafeUnpin for Sndu<'a>

§

impl<'a> UnwindSafe for Sndu<'a>

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.

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.