pub trait ParseBuffer: ShrinkBuffer + ContiguousBuffer {
// Required method
fn parse_with<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs,
) -> Result<P, P::Error>;
// Provided method
fn parse<'a, P: ParsablePacket<&'a [u8], ()>>(
&'a mut self,
) -> Result<P, P::Error> { ... }
}
Expand description
A byte buffer used for parsing.
A ParseBuffer
is a ContiguousBuffer
that can shrink in size.
While a ParseBuffer
allows the ranges covered by its prefix, body, and
suffix to be modified, it only provides immutable access to their contents.
For mutable access, see ParseBufferMut
.
§Notable implementations
ParseBuffer
is implemented for byte slices - &[u8]
and &mut [u8]
.
These types do not implement GrowBuffer
; once bytes are consumed from
their bodies, those bytes are discarded and cannot be recovered.
Required Methods§
Sourcefn parse_with<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs,
) -> Result<P, P::Error>
fn parse_with<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>( &'a mut self, args: ParseArgs, ) -> Result<P, P::Error>
Provided Methods§
Sourcefn parse<'a, P: ParsablePacket<&'a [u8], ()>>(
&'a mut self,
) -> Result<P, P::Error>
fn parse<'a, P: ParsablePacket<&'a [u8], ()>>( &'a mut self, ) -> Result<P, P::Error>
Parses a packet from the body.
parse
parses a packet from the body by invoking P::parse
on a
BufferView
into this buffer. Any bytes consumed from the
BufferView
are also consumed from the body, and added to the prefix or
suffix. After parse
has returned, the buffer’s body will contain only
those bytes which were not consumed by the call to P::parse
.
See the BufferView
and ParsablePacket
documentation for more
details.
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.