pub struct EthernetPacket {
pub header: EthernetHeader,
pub payload: Bytes,
}Expand description
Represents an Ethernet packet.
Fields§
§header: EthernetHeaderThe Ethernet header.
payload: BytesImplementations§
Source§impl EthernetPacket
impl EthernetPacket
Sourcepub fn new(header: EthernetHeader, payload: Bytes) -> Self
pub fn new(header: EthernetHeader, payload: Bytes) -> Self
Create a new Ethernet packet.
Sourcepub fn get_destination(&self) -> MacAddr
pub fn get_destination(&self) -> MacAddr
Get the destination MAC address.
Sourcepub fn get_source(&self) -> MacAddr
pub fn get_source(&self) -> MacAddr
Get the source MAC address.
Sourcepub fn get_ethertype(&self) -> EtherType
pub fn get_ethertype(&self) -> EtherType
Get the EtherType.
pub fn ip_packet(&self) -> Option<Bytes>
Trait Implementations§
Source§impl Clone for EthernetPacket
impl Clone for EthernetPacket
Source§fn clone(&self) -> EthernetPacket
fn clone(&self) -> EthernetPacket
Returns a duplicate 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 EthernetPacket
impl Debug for EthernetPacket
Source§impl Display for EthernetPacket
impl Display for EthernetPacket
Source§impl Packet for EthernetPacket
impl Packet for EthernetPacket
type Header = EthernetHeader
Source§fn from_bytes(bytes: Bytes) -> Option<Self>
fn from_bytes(bytes: Bytes) -> Option<Self>
Parse from raw bytes. (with ownership)
Source§fn header_len(&self) -> usize
fn header_len(&self) -> usize
Get the length of the header.
Source§fn payload_len(&self) -> usize
fn payload_len(&self) -> usize
Get the length of the payload.
fn into_parts(self) -> (Self::Header, Bytes)
Source§fn to_bytes_mut(&self) -> BytesMut
fn to_bytes_mut(&self) -> BytesMut
Convert the packet to a mutable byte buffer.
Source§fn header_mut(&self) -> BytesMut
fn header_mut(&self) -> BytesMut
Get a mutable byte buffer for the header.
Source§fn payload_mut(&self) -> BytesMut
fn payload_mut(&self) -> BytesMut
Get a mutable byte buffer for the payload.
Source§impl PartialEq for EthernetPacket
impl PartialEq for EthernetPacket
impl Eq for EthernetPacket
impl StructuralPartialEq for EthernetPacket
Auto Trait Implementations§
impl !Freeze for EthernetPacket
impl RefUnwindSafe for EthernetPacket
impl Send for EthernetPacket
impl Sync for EthernetPacket
impl Unpin for EthernetPacket
impl UnwindSafe for EthernetPacket
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