Skip to main content

EthernetFrameBuilder

Struct EthernetFrameBuilder 

Source
pub struct EthernetFrameBuilder<'a> { /* private fields */ }
Expand description

Ethernet II frame construction. Ethernet II frame construction. Ethernet II frame construction. An allocation-free builder for an Ethernet II header in a caller-provided buffer.

It writes the destination, source, and protocol-type header specified by RFC 894, never generates FCS bytes, and leaves the declared payload contents to the caller.

Implementations§

Source§

impl<'a> EthernetFrameBuilder<'a>

Source

pub fn new(buffer: &'a mut [u8], payload_length: usize) -> Self

Starts construction in buffer with an explicit payload length.

build will represent exactly the RFC 894 header followed by this many payload octets; it does not write payload and never generates FCS bytes.

Source

pub fn destination(self, destination: MacAddress) -> Self

Supplies the destination address for the Ethernet header in RFC 894.

Source

pub fn source(self, source: MacAddress) -> Self

Supplies the source address for the Ethernet header in RFC 894.

Source

pub fn ether_type(self, ether_type: EtherType) -> Self

Supplies the protocol type for the Ethernet header in RFC 894.

Source

pub fn build(self) -> Result<EthernetFrameMut<'a>, EthernetFrameBuildError>

Validates required fields and capacity, then writes exactly the Ethernet II header.

Validation completes before any write. On success, the returned view is restricted to the RFC 894 header plus the declared payload; payload and trailing capacity are unchanged, and FCS bytes are never generated.

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