pub struct EthernetFrame<T: AsRef<[u8]>> { /* private fields */ }
Expand description
A read/write wrapper around an Ethernet II frame buffer.
Implementations§
Source§impl<T: AsRef<[u8]>> Frame<T>
impl<T: AsRef<[u8]>> Frame<T>
Sourcepub const fn new_unchecked(buffer: T) -> Frame<T>
pub const fn new_unchecked(buffer: T) -> Frame<T>
Imbue a raw octet buffer with Ethernet frame structure.
Sourcepub fn new_checked(buffer: T) -> Result<Frame<T>>
pub fn new_checked(buffer: T) -> Result<Frame<T>>
Shorthand for a combination of new_unchecked and check_len.
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Ensure that no accessor method will panic if called.
Returns Err(Error)
if the buffer is too short.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the frame, returning the underlying buffer.
Sourcepub const fn header_len() -> usize
pub const fn header_len() -> usize
Return the length of a frame header.
Sourcepub const fn buffer_len(payload_len: usize) -> usize
pub const fn buffer_len(payload_len: usize) -> usize
Return the length of a buffer required to hold a packet with the payload of a given length.
Source§impl<T: AsRef<[u8]> + AsMut<[u8]>> Frame<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> Frame<T>
Sourcepub fn set_dst_addr(&mut self, value: Address)
pub fn set_dst_addr(&mut self, value: Address)
Set the destination address field.
Sourcepub fn set_src_addr(&mut self, value: Address)
pub fn set_src_addr(&mut self, value: Address)
Set the source address field.
Sourcepub fn set_ethertype(&mut self, value: EtherType)
pub fn set_ethertype(&mut self, value: EtherType)
Set the EtherType field.
Sourcepub fn payload_mut(&mut self) -> &mut [u8]
pub fn payload_mut(&mut self) -> &mut [u8]
Return a mutable pointer to the payload.
Trait Implementations§
Source§impl<T: AsRef<[u8]>> PrettyPrint for Frame<T>
impl<T: AsRef<[u8]>> PrettyPrint for Frame<T>
Source§fn pretty_print(
buffer: &dyn AsRef<[u8]>,
f: &mut Formatter<'_>,
indent: &mut PrettyIndent,
) -> Result
fn pretty_print( buffer: &dyn AsRef<[u8]>, f: &mut Formatter<'_>, indent: &mut PrettyIndent, ) -> Result
Write a concise, formatted representation of a packet contained in the provided
buffer, and any nested packets it may contain. Read more
Auto Trait Implementations§
impl<T> Freeze for Frame<T>where
T: Freeze,
impl<T> RefUnwindSafe for Frame<T>where
T: RefUnwindSafe,
impl<T> Send for Frame<T>where
T: Send,
impl<T> Sync for Frame<T>where
T: Sync,
impl<T> Unpin for Frame<T>where
T: Unpin,
impl<T> UnwindSafe for Frame<T>where
T: UnwindSafe,
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, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)