pub trait MutablePacket<'a>: Sized {
type Packet: Packet;
// Required methods
fn new(buffer: &'a mut [u8]) -> Option<Self>;
fn packet(&self) -> &[u8] ⓘ;
fn packet_mut(&mut self) -> &mut [u8] ⓘ;
fn header(&self) -> &[u8] ⓘ;
fn header_mut(&mut self) -> &mut [u8] ⓘ;
fn payload(&self) -> &[u8] ⓘ;
fn payload_mut(&mut self) -> &mut [u8] ⓘ;
// Provided method
fn freeze(&self) -> Option<Self::Packet> { ... }
}Expand description
Represents a mutable network packet that can be parsed and modified in place.
Types implementing this trait work on top of the same backing buffer and allow layered packet parsing to be chained without additional allocations.
Required Associated Types§
Required Methods§
Sourcefn new(buffer: &'a mut [u8]) -> Option<Self>
fn new(buffer: &'a mut [u8]) -> Option<Self>
Construct a mutable packet from the provided buffer.
Sourcefn packet_mut(&mut self) -> &mut [u8] ⓘ
fn packet_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable view over the entire packet buffer.
Sourcefn header_mut(&mut self) -> &mut [u8] ⓘ
fn header_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable view over the serialized header bytes of the packet.
Sourcefn payload_mut(&mut self) -> &mut [u8] ⓘ
fn payload_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable view over the payload bytes of the packet.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.