MutablePacket

Trait MutablePacket 

Source
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§

Source

type Packet: Packet

The immutable packet type associated with this mutable view.

Required Methods§

Source

fn new(buffer: &'a mut [u8]) -> Option<Self>

Construct a mutable packet from the provided buffer.

Source

fn packet(&self) -> &[u8]

Get a shared view over the entire packet buffer.

Source

fn packet_mut(&mut self) -> &mut [u8]

Get a mutable view over the entire packet buffer.

Source

fn header(&self) -> &[u8]

Get the serialized header bytes of the packet.

Source

fn header_mut(&mut self) -> &mut [u8]

Get a mutable view over the serialized header bytes of the packet.

Source

fn payload(&self) -> &[u8]

Get the payload bytes of the packet.

Source

fn payload_mut(&mut self) -> &mut [u8]

Get a mutable view over the payload bytes of the packet.

Provided Methods§

Source

fn freeze(&self) -> Option<Self::Packet>

Convert the mutable packet into its immutable counterpart.

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.

Implementors§