Trait kafka_protocol::protocol::buf::ByteBuf
source · pub trait ByteBuf: Buf {
Show 13 methods
fn peek_bytes(&mut self, r: Range<usize>) -> Bytes;
fn get_bytes(&mut self, size: usize) -> Bytes;
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§
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 bu 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.
sourcefn try_copy_to_slice(
&mut self,
dst: &mut [u8]
) -> Result<(), NotEnoughBytesError>
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.
sourcefn try_get_u8(&mut self) -> Result<u8, NotEnoughBytesError>
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.
sourcefn try_get_u16(&mut self) -> Result<u16, NotEnoughBytesError>
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.
sourcefn try_get_u32(&mut self) -> Result<u32, NotEnoughBytesError>
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.
sourcefn try_get_i8(&mut self) -> Result<i8, NotEnoughBytesError>
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.
sourcefn try_get_i16(&mut self) -> Result<i16, NotEnoughBytesError>
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.
sourcefn try_get_i32(&mut self) -> Result<i32, NotEnoughBytesError>
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.
sourcefn try_get_i64(&mut self) -> Result<i64, NotEnoughBytesError>
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.
sourcefn try_get_f64(&mut self) -> Result<f64, NotEnoughBytesError>
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.