Skip to main content

EthernetFrameMut

Struct EthernetFrameMut 

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

Ethernet II frame views. Ethernet II frame views. Ethernet II frame views. A validated mutable borrow of one Ethernet II frame.

Its fixed header uses the destination, source, and protocol-type order described by RFC 894. Callers must remove any frame check sequence (FCS) before parsing because every supplied byte after the fixed header is payload.

Implementations§

Source§

impl<'a> EthernetFrameMut<'a>

Source

pub fn arp_mut(&mut self) -> Result<Option<ArpPacketMut<'_>>, ParseError>

Parses a mutable ARP payload only when this frame’s EtherType is ARP.

Source§

impl<'a> EthernetFrameMut<'a>

Source

pub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>

Validates and mutably borrows an Ethernet II frame.

The parser rejects inputs shorter than the 14-octet destination/source/type header described by RFC 894. Every remaining supplied octet is payload and remains available for independent protocol parsing; callers must remove any frame check sequence (FCS) before parsing.

Source

pub fn destination(&self) -> MacAddress

Returns the destination Ethernet address.

RFC 894 assigns the first six header octets to the destination address: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn source(&self) -> MacAddress

Returns the source Ethernet address.

RFC 894 assigns the next six header octets to the source address: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn ether_type(&self) -> EtherType

Returns the Ethernet protocol type.

RFC 894 places this two-octet, most-significant-octet-first field after the source address: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn set_destination(&mut self, address: MacAddress)

Replaces the destination Ethernet address.

This writes the first six header octets assigned to the destination address by RFC 894.

Source

pub fn set_source(&mut self, address: MacAddress)

Replaces the source Ethernet address.

This writes the six header octets assigned to the source address by RFC 894.

Source

pub fn set_ether_type(&mut self, ether_type: EtherType)

Replaces the Ethernet protocol type.

This writes the most-significant-octet-first type field specified by RFC 894.

Source

pub fn payload(&self) -> &[u8]

Returns the payload bytes following the fixed Ethernet II header.

This borrows the data field after the type field in RFC 894’s encapsulation: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn payload_mut(&mut self) -> &mut [u8] ⓘ

Returns mutable payload bytes following the fixed Ethernet II header.

This mutably borrows the data field after the type field in RFC 894’s encapsulation: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn as_bytes(&self) -> &[u8]

Returns all represented frame bytes.

The represented order is destination, source, type, then payload as described by RFC 894.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ

Returns all represented mutable frame bytes.

The represented order is destination, source, type, then payload as described by RFC 894.

Source§

impl<'a> EthernetFrameMut<'a>

Source

pub fn ipv4_mut(&mut self) -> Result<Option<Ipv4PacketMut<'_>>, ParseError>

Parses mutable IPv4 only for the IPv4 EtherType.

Source§

impl<'a> EthernetFrameMut<'a>

Source

pub fn ipv6_mut(&mut self) -> Result<Option<Ipv6PacketMut<'_>>, ParseError>

Parses mutable IPv6 only when this frame’s EtherType is IPv6.

Trait Implementations§

Source§

impl<'a> Debug for EthernetFrameMut<'a>

Source§

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

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

impl<'a> Eq for EthernetFrameMut<'a>

Source§

impl<'a> PartialEq for EthernetFrameMut<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for EthernetFrameMut<'a>

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for EthernetFrameMut<'a>

§

impl<'a> Freeze for EthernetFrameMut<'a>

§

impl<'a> RefUnwindSafe for EthernetFrameMut<'a>

§

impl<'a> Send for EthernetFrameMut<'a>

§

impl<'a> Sync for EthernetFrameMut<'a>

§

impl<'a> Unpin for EthernetFrameMut<'a>

§

impl<'a> UnsafeUnpin for EthernetFrameMut<'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> 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.