Struct packet::SerializeBuffer
source · pub struct SerializeBuffer<'a, 'b> { /* private fields */ }
Expand description
A view into a TargetBuffer
used for serializing new packets.
A SerializeBuffer
is a view into a TargetBuffer
which is used by the
PacketBuilder::serialize
method to serialize a new packet. It is
constructed with a contiguous header and footer, and a potentially
fragmented body, typically obtained from TargetBuffer::with_parts
.
A SerializeBuffer
provides separate access to the bytes which will store
the header, body, and footer of the new packet. The body is initialized to
contain the bytes of the packet to be encapsulated (including any padding),
and it is the caller’s responsibility to serialize the header and footer.
Implementations§
source§impl<'a, 'b> SerializeBuffer<'a, 'b>
impl<'a, 'b> SerializeBuffer<'a, 'b>
sourcepub fn new(
header: &'a mut [u8],
body: FragmentedBytesMut<'a, 'b>,
footer: &'a mut [u8]
) -> SerializeBuffer<'a, 'b>
pub fn new( header: &'a mut [u8], body: FragmentedBytesMut<'a, 'b>, footer: &'a mut [u8] ) -> SerializeBuffer<'a, 'b>
Constructs a new SerializeBuffer
.
new
constructs a new SerializeBuffer
with the provided header
,
body
, and footer
parts.
sourcepub fn body(&mut self) -> &mut FragmentedBytesMut<'a, 'b>
pub fn body(&mut self) -> &mut FragmentedBytesMut<'a, 'b>
Gets the bytes of the body.
Gets the bytes of the footer.
sourcepub fn parts(
&mut self
) -> (&mut [u8], &mut FragmentedBytesMut<'a, 'b>, &mut [u8])
pub fn parts( &mut self ) -> (&mut [u8], &mut FragmentedBytesMut<'a, 'b>, &mut [u8])
Gets the bytes of the header, body, and footer.
parts
gets references to the header, body, and footer all at once.
Because of lifetime rules and the fact that the header
, body
,
and footer
methods borrow this SerializeBuffer
, this is the only
way to construct and operate on references to more than one section of
the buffer at a time.