Skip to main content

DataItem

Enum DataItem 

Source
pub enum DataItem {
Show 21 variants Status { code: StatusCode, text: String, }, Ipv4ConnectionPoint { flags: ConnectionPointFlags, addr: Ipv4Addr, port: Option<u16>, }, Ipv6ConnectionPoint { flags: ConnectionPointFlags, addr: Ipv6Addr, port: Option<u16>, }, PeerType { flags: PeerFlags, description: String, }, HeartbeatInterval(Duration), ExtensionsSupported(Vec<ExtensionId>), MacAddress(MacAddress), Ipv4Address { add: bool, addr: Ipv4Addr, }, Ipv6Address { add: bool, addr: Ipv6Addr, }, Ipv4AttachedSubnet { add: bool, subnet: Ipv4Net, }, Ipv6AttachedSubnet { add: bool, subnet: Ipv6Net, }, MaxDataRateReceive(u64), MaxDataRateTransmit(u64), CurrentDataRateReceive(u64), CurrentDataRateTransmit(u64), Latency(Duration), Resources(u8), RelativeLinkQualityReceive(u8), RelativeLinkQualityTransmit(u8), Mtu(u16), Unknown(RawDataItem),
}
Expand description

Typed DLEP Data Item. Unknown preserves forward compatibility: the decoder never fails on an unrecognized type_id and extension code paths can introspect the raw bytes.

Variants§

§

Status

Fields

§text: String
§

Ipv4ConnectionPoint

§

Ipv6ConnectionPoint

§

PeerType

Fields

§description: String
§

HeartbeatInterval(Duration)

§

ExtensionsSupported(Vec<ExtensionId>)

§

MacAddress(MacAddress)

§

Ipv4Address

Fields

§add: bool
§

Ipv6Address

Fields

§add: bool
§

Ipv4AttachedSubnet

Fields

§add: bool
§subnet: Ipv4Net
§

Ipv6AttachedSubnet

Fields

§add: bool
§subnet: Ipv6Net
§

MaxDataRateReceive(u64)

§

MaxDataRateTransmit(u64)

§

CurrentDataRateReceive(u64)

§

CurrentDataRateTransmit(u64)

§

Latency(Duration)

§

Resources(u8)

§

RelativeLinkQualityReceive(u8)

§

RelativeLinkQualityTransmit(u8)

§

Mtu(u16)

§

Unknown(RawDataItem)

Implementations§

Source§

impl DataItem

Source

pub fn encode(&self, out: &mut BytesMut) -> Result<(), CodecError>

Encode this typed Data Item — including its 4-byte TLV header — onto out. Writes directly into the caller’s buffer; on error out is restored to its starting length so the caller can recover.

Returns an error for values that cannot be expressed on the wire:

  • Resources / RelativeLinkQuality{Receive,Transmit} outside 0..=100 (per RFC 8175 §13.17–§13.19)
  • HeartbeatInterval whose milliseconds exceed u32::MAX
  • Latency whose microseconds exceed u64::MAX

Ipv4AttachedSubnet / Ipv6AttachedSubnet always emit the network address (host bits truncated to the prefix), per RFC 8175 §13.10–§13.11. decode symmetrically truncates non-canonical input, so a peer that puts host bits on the wire is normalized in memory rather than silently re-canonicalized on the next encode.

Source

pub fn decode(raw: RawDataItem) -> Result<Self, CodecError>

Lift a parsed RawDataItem into a typed DataItem. Unknown type ids fall through to DataItem::Unknown for negotiated extension dispatch. The session layer rejects unclaimed items under RFC 8175 §12.1. Length errors and value-range errors are reported here.

Ipv4AttachedSubnet / Ipv6AttachedSubnet are normalized to network form here — host bits in non-canonical wire input are zeroed so the in-memory representation matches what encode would produce, and equality comparisons across peer-sent subnets are stable.

Source§

impl DataItem

Source

pub fn type_id(&self) -> DataItemType

Trait Implementations§

Source§

impl Clone for DataItem

Source§

fn clone(&self) -> Self

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 Debug for DataItem

Source§

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

Formats the value using the given formatter. Read more

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.