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>
impl<'a> EthernetFrameBuilder<'a>
Sourcepub fn new(buffer: &'a mut [u8], payload_length: usize) -> Self
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.
Sourcepub fn destination(self, destination: MacAddress) -> Self
pub fn destination(self, destination: MacAddress) -> Self
Supplies the destination address for the Ethernet header in RFC 894.
Sourcepub fn source(self, source: MacAddress) -> Self
pub fn source(self, source: MacAddress) -> Self
Supplies the source address for the Ethernet header in RFC 894.
Sourcepub fn ether_type(self, ether_type: EtherType) -> Self
pub fn ether_type(self, ether_type: EtherType) -> Self
Supplies the protocol type for the Ethernet header in RFC 894.
Sourcepub fn build(self) -> Result<EthernetFrameMut<'a>, EthernetFrameBuildError>
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.