Struct etherparse::Ethernet2Slice
source · pub struct Ethernet2Slice<'a> { /* private fields */ }
Expand description
Slice containing an Ethernet 2 headers & payload.
Implementations§
source§impl<'a> Ethernet2Slice<'a>
impl<'a> Ethernet2Slice<'a>
sourcepub fn from_slice_without_fcs(
slice: &'a [u8],
) -> Result<Ethernet2Slice<'a>, LenError>
pub fn from_slice_without_fcs( slice: &'a [u8], ) -> Result<Ethernet2Slice<'a>, LenError>
Try creating a Ethernet2Slice
from a slice containing the
Ethernet 2 header & payload WITHOUT an FCS (frame check sequence)
at the end.
sourcepub fn from_slice_with_crc32_fcs(
slice: &'a [u8],
) -> Result<Ethernet2Slice<'a>, LenError>
pub fn from_slice_with_crc32_fcs( slice: &'a [u8], ) -> Result<Ethernet2Slice<'a>, LenError>
Try creating a Ethernet2Slice
from a slice containing the
Ethernet 2 header & payload with a CRC 32 bit FCS (frame
check sequence) at the end.
In case you are not sure if your ethernet2 frame has a FCS or not
use Ethernet2Slice::from_slice_without_fcs
instead and rely on the
lower layers (e.g. IP) to determine the correct payload length.
sourcepub fn slice(&self) -> &'a [u8] ⓘ
pub fn slice(&self) -> &'a [u8] ⓘ
Returns the slice containing the ethernet 2 header payload and FCS if present.
sourcepub fn destination(&self) -> [u8; 6]
pub fn destination(&self) -> [u8; 6]
Read the destination MAC address
sourcepub fn ether_type(&self) -> EtherType
pub fn ether_type(&self) -> EtherType
Read the ether_type field of the header indicating the protocol after the header.
sourcepub fn to_header(&self) -> Ethernet2Header
pub fn to_header(&self) -> Ethernet2Header
Decode all the fields and copy the results to a Ethernet2Header
struct
sourcepub fn header_slice(&self) -> &[u8] ⓘ
pub fn header_slice(&self) -> &[u8] ⓘ
Slice containing the Ethernet 2 header.
sourcepub fn payload(&self) -> EtherPayloadSlice<'a>
pub fn payload(&self) -> EtherPayloadSlice<'a>
Returns the slice containing the Ethernet II payload & ether type identifying it’s content type.
sourcepub fn payload_slice(&self) -> &'a [u8] ⓘ
pub fn payload_slice(&self) -> &'a [u8] ⓘ
Returns the slice containing the Ethernet II payload.
sourcepub const fn header_len(&self) -> usize
pub const fn header_len(&self) -> usize
Length of the Ethernet 2 header in bytes (equal to
crate::Ethernet2Header::LEN
).
Trait Implementations§
source§impl<'a> Clone for Ethernet2Slice<'a>
impl<'a> Clone for Ethernet2Slice<'a>
source§fn clone(&self) -> Ethernet2Slice<'a>
fn clone(&self) -> Ethernet2Slice<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for Ethernet2Slice<'a>
impl<'a> Debug for Ethernet2Slice<'a>
source§impl<'a> PartialEq for Ethernet2Slice<'a>
impl<'a> PartialEq for Ethernet2Slice<'a>
impl<'a> Eq for Ethernet2Slice<'a>
impl<'a> StructuralPartialEq for Ethernet2Slice<'a>
Auto Trait Implementations§
impl<'a> Freeze for Ethernet2Slice<'a>
impl<'a> RefUnwindSafe for Ethernet2Slice<'a>
impl<'a> Send for Ethernet2Slice<'a>
impl<'a> Sync for Ethernet2Slice<'a>
impl<'a> Unpin for Ethernet2Slice<'a>
impl<'a> UnwindSafe for Ethernet2Slice<'a>
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
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)
clone_to_uninit
)