Skip to main content

EthernetFrame

Struct EthernetFrame 

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

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

The fixed destination, source, and protocol-type header order follows 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> EthernetFrame<'a>

Source

pub fn arp(&self) -> Result<Option<ArpPacket<'a>>, ParseError>

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

Source§

impl<'a> EthernetFrame<'a>

Source

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

Validates and 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 exposed unchanged as payload; callers must remove any frame check sequence (FCS) before parsing. No minimum payload length is imposed by this wire view.

Source

pub fn destination(&self) -> MacAddress

Returns the destination Ethernet address.

RFC 894 places the destination address in the first six octets of the Ethernet header: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn source(&self) -> MacAddress

Returns the source Ethernet address.

RFC 894 places the source address immediately after the destination address: https://www.rfc-editor.org/rfc/rfc894.

Source

pub fn ether_type(&self) -> EtherType

Returns the Ethernet protocol type.

RFC 894 places the two-octet protocol type after the source address and transmits it most-significant octet first: https://www.rfc-editor.org/rfc/rfc894.

Source

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

Returns the payload bytes following the fixed Ethernet II header.

This is the data field after the type field in the RFC 894 Ethernet encapsulation: https://www.rfc-editor.org/rfc/rfc894. The returned slice borrows the input.

Source

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

Returns all represented frame bytes.

The byte layout is the destination/source/type/payload order described by RFC 894. Callers must remove any frame check sequence (FCS) before parsing; it cannot be distinguished from payload here.

Source§

impl<'a> EthernetFrame<'a>

Source

pub fn ipv4(&self) -> Result<Option<Ipv4Packet<'a>>, ParseError>

Parses IPv4 only for the IPv4 EtherType.

Source§

impl<'a> EthernetFrame<'a>

Source

pub fn ipv6(&self) -> Result<Option<Ipv6Packet<'a>>, ParseError>

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

Trait Implementations§

Source§

impl<'a> Clone for EthernetFrame<'a>

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<'a> Copy for EthernetFrame<'a>

Source§

impl<'a> Debug for EthernetFrame<'a>

Source§

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

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

impl<'a> Eq for EthernetFrame<'a>

Source§

impl<'a> PartialEq for EthernetFrame<'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 EthernetFrame<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for EthernetFrame<'a>

§

impl<'a> RefUnwindSafe for EthernetFrame<'a>

§

impl<'a> Send for EthernetFrame<'a>

§

impl<'a> Sync for EthernetFrame<'a>

§

impl<'a> Unpin for EthernetFrame<'a>

§

impl<'a> UnsafeUnpin for EthernetFrame<'a>

§

impl<'a> UnwindSafe for EthernetFrame<'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, 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.