pub struct Ethernet2Header {
    pub source: [u8; 6],
    pub destination: [u8; 6],
    pub ether_type: EtherType,
}
Expand description

Ethernet II header.

Fields§

§source: [u8; 6]

Source MAC Address

§destination: [u8; 6]

Destination MAC Address

§ether_type: EtherType

Protocol present after the ethernet2 header.

Implementations§

source§

impl Ethernet2Header

source

pub const LEN: usize = 14usize

Serialized size of an Ethernet2 header in bytes/octets.

source

pub const SERIALIZED_SIZE: usize = 14usize

👎Deprecated since 0.14.0: Use Ethernet2Header::LEN instead

Deprecated use Ethernet2Header::LEN instead.

source

pub fn read_from_slice( slice: &[u8] ) -> Result<(Ethernet2Header, &[u8]), LenError>

👎Deprecated since 0.10.1: Use Ethernet2Header::from_slice instead.

Deprecated use Ethernet2Header::from_slice instead.

source

pub fn from_slice(slice: &[u8]) -> Result<(Ethernet2Header, &[u8]), LenError>

Read an Ethernet2Header from a slice and return the header & unused parts of the slice.

source

pub fn from_bytes(bytes: [u8; 14]) -> Ethernet2Header

Read an Ethernet2Header from a static sized byte array.

source

pub fn read<T: Read + Seek + Sized>( reader: &mut T ) -> Result<Ethernet2Header, Error>

Available on crate feature std only.

Reads an Ethernet-II header from the current position of the read argument.

source

pub fn write_to_slice<'a>( &self, slice: &'a mut [u8] ) -> Result<&'a mut [u8], SliceWriteSpaceError>

Serialize the header to a given slice. Returns the unused part of the slice.

source

pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>

Available on crate feature std only.

Writes a given Ethernet-II header to the current position of the write argument.

source

pub fn header_len(&self) -> usize

Length of the serialized header in bytes.

source

pub fn to_bytes(&self) -> [u8; 14]

Returns the serialized form of the header as a statically sized byte array.

Trait Implementations§

source§

impl Clone for Ethernet2Header

source§

fn clone(&self) -> Ethernet2Header

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Ethernet2Header

source§

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

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

impl Default for Ethernet2Header

source§

fn default() -> Ethernet2Header

Returns the “default value” for a type. Read more
source§

impl PartialEq for Ethernet2Header

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Ethernet2Header

source§

impl StructuralPartialEq for Ethernet2Header

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> ToOwned for T
where T: Clone,

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.