Trait ByteBuf

Source
pub trait ByteBuf: Buf {
Show 13 methods // 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> { ... } fn try_copy_to_slice( &mut self, dst: &mut [u8], ) -> Result<(), NotEnoughBytesError> { ... } fn try_get_u8(&mut self) -> Result<u8, NotEnoughBytesError> { ... } fn try_get_u16(&mut self) -> Result<u16, NotEnoughBytesError> { ... } fn try_get_u32(&mut self) -> Result<u32, NotEnoughBytesError> { ... } fn try_get_i8(&mut self) -> Result<i8, NotEnoughBytesError> { ... } fn try_get_i16(&mut self) -> Result<i16, NotEnoughBytesError> { ... } fn try_get_i32(&mut self) -> Result<i32, NotEnoughBytesError> { ... } fn try_get_i64(&mut self) -> Result<i64, NotEnoughBytesError> { ... } fn try_get_f64(&mut self) -> Result<f64, NotEnoughBytesError> { ... }
}
Expand description

Extension for working with bytes::Buf.

Required Methods§

Source

fn peek_bytes(&mut self, r: Range<usize>) -> Bytes

Peek ahead in the buffer by the provided range.

Source

fn get_bytes(&mut self, size: usize) -> Bytes

Get size bytes from the underlying buffer.

Provided Methods§

Source

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.

Source

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.

Source

fn try_copy_to_slice( &mut self, dst: &mut [u8], ) -> Result<(), NotEnoughBytesError>

Attempt to copy from buffer into destination slice, returning an error if not enough space remains.

Source

fn try_get_u8(&mut self) -> Result<u8, NotEnoughBytesError>

Attempt to read a u8 from the buffer, returning an error if not enough space remains.

Source

fn try_get_u16(&mut self) -> Result<u16, NotEnoughBytesError>

Attempt to read a u16 from the buffer, returning an error if not enough space remains.

Source

fn try_get_u32(&mut self) -> Result<u32, NotEnoughBytesError>

Attempt to read a u32 from the buffer, returning an error if not enough space remains.

Source

fn try_get_i8(&mut self) -> Result<i8, NotEnoughBytesError>

Attempt to read a i8 from the buffer, returning an error if not enough space remains.

Source

fn try_get_i16(&mut self) -> Result<i16, NotEnoughBytesError>

Attempt to read a i16 from the buffer, returning an error if not enough space remains.

Source

fn try_get_i32(&mut self) -> Result<i32, NotEnoughBytesError>

Attempt to read a i32 from the buffer, returning an error if not enough space remains.

Source

fn try_get_i64(&mut self) -> Result<i64, NotEnoughBytesError>

Attempt to read a i64 from the buffer, returning an error if not enough space remains.

Source

fn try_get_f64(&mut self) -> Result<f64, NotEnoughBytesError>

Attempt to read a f32 from the buffer, returning an error if not enough space remains.

Implementations on Foreign Types§

Source§

impl ByteBuf for &[u8]

Source§

fn peek_bytes(&mut self, r: Range<usize>) -> Bytes

Source§

fn get_bytes(&mut self, size: usize) -> Bytes

Source§

impl ByteBuf for Bytes

Source§

fn peek_bytes(&mut self, r: Range<usize>) -> Bytes

Source§

fn get_bytes(&mut self, size: usize) -> Bytes

Source§

impl ByteBuf for BytesMut

Source§

fn peek_bytes(&mut self, r: Range<usize>) -> Bytes

Source§

fn get_bytes(&mut self, size: usize) -> Bytes

Source§

impl<T: AsRef<[u8]>> ByteBuf for Cursor<T>

Source§

fn peek_bytes(&mut self, r: Range<usize>) -> Bytes

Source§

fn get_bytes(&mut self, size: usize) -> Bytes

Source§

impl<T: ByteBuf> ByteBuf for &mut T

Implementors§