Struct netsim_embed::ethernet::MutableEthernetPacket
source · pub struct MutableEthernetPacket<'p> { /* private fields */ }Expand description
A structure enabling manipulation of on the wire packets
Implementations§
source§impl<'a> MutableEthernetPacket<'a>
impl<'a> MutableEthernetPacket<'a>
sourcepub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableEthernetPacket<'p>>
pub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableEthernetPacket<'p>>
Constructs a new #name. If the provided buffer is less than the minimum required packet size, this will return None.
sourcepub fn owned(packet: Vec<u8, Global>) -> Option<MutableEthernetPacket<'static>>
pub fn owned(packet: Vec<u8, Global>) -> Option<MutableEthernetPacket<'static>>
Constructs a new #name. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the #name will own its own data and the underlying buffer will be dropped when the #name is.
sourcepub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
pub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
Maps from a #name to a #imm_name
sourcepub fn consume_to_immutable(self) -> EthernetPacket<'a>
pub fn consume_to_immutable(self) -> EthernetPacket<'a>
Maps from a #name to a #imm_name while consuming the source
sourcepub const fn minimum_packet_size() -> usize
pub const fn minimum_packet_size() -> usize
The minimum size (in bytes) a packet of this type can be. It’s based on the total size of the fixed-size fields.
sourcepub fn packet_size(_packet: &Ethernet) -> usize
pub fn packet_size(_packet: &Ethernet) -> usize
The size (in bytes) of a #base_name instance when converted into a byte-array
sourcepub fn populate(&mut self, packet: &Ethernet)
pub fn populate(&mut self, packet: &Ethernet)
Populates a {name}Packet using a {name} structure
sourcepub fn get_destination(&self) -> MacAddr
pub fn get_destination(&self) -> MacAddr
Get the value of the {name} field
sourcepub fn get_source(&self) -> MacAddr
pub fn get_source(&self) -> MacAddr
Get the value of the {name} field
sourcepub fn get_ethertype(&self) -> EtherType
pub fn get_ethertype(&self) -> EtherType
Get the value of the {name} field
sourcepub fn get_payload(&self) -> Vec<u8, Global>
pub fn get_payload(&self) -> Vec<u8, Global>
Get the value of the {name} field (copies contents)
sourcepub fn set_destination(&mut self, val: MacAddr)
pub fn set_destination(&mut self, val: MacAddr)
Set the value of the {name} field.
sourcepub fn set_source(&mut self, val: MacAddr)
pub fn set_source(&mut self, val: MacAddr)
Set the value of the {name} field.
sourcepub fn set_ethertype(&mut self, val: EtherType)
pub fn set_ethertype(&mut self, val: EtherType)
Set the value of the {name} field.
sourcepub fn set_payload(&mut self, vals: &[u8])
pub fn set_payload(&mut self, vals: &[u8])
Set the value of the {name} field (copies contents)