Struct smoltcp::wire::EthernetFrame
source · 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