#[repr(C)]pub struct EthernetHeader {
pub dest_mac: [u8; 6],
pub src_mac: [u8; 6],
pub ether_type: u16,
}Expand description
Ethernet frame header (14 bytes)
Fields§
§dest_mac: [u8; 6]Destination MAC address (6 bytes)
src_mac: [u8; 6]Source MAC address (6 bytes)
ether_type: u16EtherType (2 bytes) - protocol identifier
Implementations§
Source§impl EthernetHeader
impl EthernetHeader
Sourcepub fn new(dest_mac: [u8; 6], src_mac: [u8; 6], ether_type: u16) -> Self
pub fn new(dest_mac: [u8; 6], src_mac: [u8; 6], ether_type: u16) -> Self
Create a new Ethernet header
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Parse header from bytes
Sourcepub fn ether_type_be(&self) -> [u8; 2]
pub fn ether_type_be(&self) -> [u8; 2]
Get EtherType as big-endian bytes
Trait Implementations§
Source§impl Clone for EthernetHeader
impl Clone for EthernetHeader
Source§fn clone(&self) -> EthernetHeader
fn clone(&self) -> EthernetHeader
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EthernetHeader
impl Debug for EthernetHeader
impl Copy for EthernetHeader
Auto Trait Implementations§
impl Freeze for EthernetHeader
impl RefUnwindSafe for EthernetHeader
impl Send for EthernetHeader
impl Sync for EthernetHeader
impl Unpin for EthernetHeader
impl UnwindSafe for EthernetHeader
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)