Struct etherparse::Ethernet2Header
source · 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
impl Ethernet2Header
sourcepub const SERIALIZED_SIZE: usize = 14usize
👎Deprecated since 0.14.0: Use Ethernet2Header::LEN
instead
pub const SERIALIZED_SIZE: usize = 14usize
Ethernet2Header::LEN
insteadDeprecated use Ethernet2Header::LEN
instead.
sourcepub fn read_from_slice(
slice: &[u8],
) -> Result<(Ethernet2Header, &[u8]), LenError>
👎Deprecated since 0.10.1: Use Ethernet2Header::from_slice instead.
pub fn read_from_slice( slice: &[u8], ) -> Result<(Ethernet2Header, &[u8]), LenError>
Deprecated use Ethernet2Header::from_slice
instead.
sourcepub fn from_slice(slice: &[u8]) -> Result<(Ethernet2Header, &[u8]), LenError>
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.
sourcepub fn from_bytes(bytes: [u8; 14]) -> Ethernet2Header
pub fn from_bytes(bytes: [u8; 14]) -> Ethernet2Header
Read an Ethernet2Header from a static sized byte array.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T,
) -> Result<Ethernet2Header, Error>
Available on crate feature std
only.
pub fn read<T: Read + Seek + Sized>( reader: &mut T, ) -> Result<Ethernet2Header, Error>
std
only.Reads an Ethernet-II header from the current position of the read argument.
sourcepub fn write_to_slice<'a>(
&self,
slice: &'a mut [u8],
) -> Result<&'a mut [u8], SliceWriteSpaceError>
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.
sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
Available on crate feature std
only.
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
std
only.Writes a given Ethernet-II header to the current position of the write argument.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the serialized header in bytes.
Trait Implementations§
source§impl Clone for Ethernet2Header
impl Clone for Ethernet2Header
source§fn clone(&self) -> Ethernet2Header
fn clone(&self) -> Ethernet2Header
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Ethernet2Header
impl Debug for Ethernet2Header
source§impl Default for Ethernet2Header
impl Default for Ethernet2Header
source§fn default() -> Ethernet2Header
fn default() -> Ethernet2Header
Returns the “default value” for a type. Read more
source§impl PartialEq for Ethernet2Header
impl PartialEq for Ethernet2Header
impl Eq for Ethernet2Header
impl StructuralPartialEq for Ethernet2Header
Auto Trait Implementations§
impl Freeze for Ethernet2Header
impl RefUnwindSafe for Ethernet2Header
impl Send for Ethernet2Header
impl Sync for Ethernet2Header
impl Unpin for Ethernet2Header
impl UnwindSafe for Ethernet2Header
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)