Trait packet::ParseBufferMut
source · pub trait ParseBufferMut: ParseBuffer + FragmentedBufferMut + ContiguousBufferMut {
// Required method
fn parse_with_mut<'a, ParseArgs, P: ParsablePacket<&'a mut [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs
) -> Result<P, P::Error>;
// Provided method
fn parse_mut<'a, P: ParsablePacket<&'a mut [u8], ()>>(
&'a mut self
) -> Result<P, P::Error> { ... }
}
Expand description
A ParseBuffer
which provides mutable access to its contents.
While a ParseBuffer
allows the ranges covered by its prefix, body, and
suffix to be modified, it only provides immutable access to their contents.
A ParseBufferMut
, on the other hand, provides mutable access to the
contents of its prefix, body, and suffix.
Notable implementations
ParseBufferMut
is implemented for mutable byte slices - &mut [u8]
.
Mutable byte slices do not implement GrowBuffer
or GrowBufferMut
;
once bytes are consumed from their bodies, those bytes are discarded and
cannot be recovered.
Required Methods§
sourcefn parse_with_mut<'a, ParseArgs, P: ParsablePacket<&'a mut [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs
) -> Result<P, P::Error>
fn parse_with_mut<'a, ParseArgs, P: ParsablePacket<&'a mut [u8], ParseArgs>>( &'a mut self, args: ParseArgs ) -> Result<P, P::Error>
Parses a mutable packet with arguments.
parse_with_mut
is like parse_mut
, but it accepts arguments to pass
to P::parse_mut
.
Provided Methods§
sourcefn parse_mut<'a, P: ParsablePacket<&'a mut [u8], ()>>(
&'a mut self
) -> Result<P, P::Error>
fn parse_mut<'a, P: ParsablePacket<&'a mut [u8], ()>>( &'a mut self ) -> Result<P, P::Error>
Parses a mutable packet from the body.
parse_mut
is like ParseBuffer::parse
, but instead of calling
P::parse
on a BufferView
, it calls P::parse_mut
on a
BufferViewMut
. The effect is that the parsed packet can contain
mutable references to the buffer. This can be useful if you want to
modify parsed packets in-place.
Depending on the implementation of P::parse_mut
, the contents
of the buffer may be modified during parsing.
See the BufferViewMut
and ParsablePacket
documentation for more
details.