pub trait ByteBuf: Buf {
// Required methods
fn peek_bytes(&mut self, r: Range<usize>) -> Bytes;
fn get_bytes(&mut self, size: usize) -> Bytes;
// Provided methods
fn try_peek_bytes(
&mut self,
r: Range<usize>,
) -> Result<Bytes, NotEnoughBytesError> { ... }
fn try_get_bytes(
&mut self,
size: usize,
) -> Result<Bytes, NotEnoughBytesError> { ... }
}
Expand description
Extension for working with bytes::Buf
.
Required Methods§
Sourcefn peek_bytes(&mut self, r: Range<usize>) -> Bytes
fn peek_bytes(&mut self, r: Range<usize>) -> Bytes
Peek ahead in the buffer by the provided range.
Provided Methods§
Sourcefn try_peek_bytes(
&mut self,
r: Range<usize>,
) -> Result<Bytes, NotEnoughBytesError>
fn try_peek_bytes( &mut self, r: Range<usize>, ) -> Result<Bytes, NotEnoughBytesError>
Try to peek ahead in the buffer by the provided range, returning an error if there are less bytes than the requested range.
Sourcefn try_get_bytes(&mut self, size: usize) -> Result<Bytes, NotEnoughBytesError>
fn try_get_bytes(&mut self, size: usize) -> Result<Bytes, NotEnoughBytesError>
Try to get size
bytes from the buffer, returning an error if there are less bytes than the
requested number.