pub trait SafeBuf: Buf {
Show 22 methods
// Provided methods
fn try_copy_to_bytes(&mut self, len: usize) -> Result<Bytes, Truncated> { ... }
fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), Truncated> { ... }
fn extract<T>(&mut self) -> Result<T>
where T: FromBuf { ... }
fn should_be_exhausted(&self) -> Result<(), ExtraneousBytes> { ... }
fn try_get_u8(&mut self) -> Result<u8, Truncated> { ... }
fn try_get_i8(&mut self) -> Result<i8, Truncated> { ... }
fn try_get_u16(&mut self) -> Result<u16, Truncated> { ... }
fn try_get_i16(&mut self) -> Result<i16, Truncated> { ... }
fn try_get_u32(&mut self) -> Result<u32, Truncated> { ... }
fn try_get_i32(&mut self) -> Result<i32, Truncated> { ... }
fn try_get_u64(&mut self) -> Result<u64, Truncated> { ... }
fn try_get_i64(&mut self) -> Result<i64, Truncated> { ... }
fn try_get_u128(&mut self) -> Result<u128, Truncated> { ... }
fn try_get_i128(&mut self) -> Result<i128, Truncated> { ... }
fn try_get_u16_le(&mut self) -> Result<u16, Truncated> { ... }
fn try_get_i16_le(&mut self) -> Result<i16, Truncated> { ... }
fn try_get_u32_le(&mut self) -> Result<u32, Truncated> { ... }
fn try_get_i32_le(&mut self) -> Result<i32, Truncated> { ... }
fn try_get_u64_le(&mut self) -> Result<u64, Truncated> { ... }
fn try_get_i64_le(&mut self) -> Result<i64, Truncated> { ... }
fn try_get_u128_le(&mut self) -> Result<u128, Truncated> { ... }
fn try_get_i128_le(&mut self) -> Result<i128, Truncated> { ... }
}Expand description
Extension trait for bytes::Buf
Provided Methods§
Sourcefn try_copy_to_bytes(&mut self, len: usize) -> Result<Bytes, Truncated>
fn try_copy_to_bytes(&mut self, len: usize) -> Result<Bytes, Truncated>
Take a given number of bytes from the buffer, with a check to ensure there are enough remaining
§Errors
This method will return an error if the number of bytes remaining in the buffer is insufficent
Sourcefn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), Truncated>
fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), Truncated>
Take a given number of bytes from the buffer and write to a slice, with a check to ensure there are enough remaining
§Errors
This method will return an error if the number of bytes remaining in the buffer is insufficent
Sourcefn extract<T>(&mut self) -> Result<T>where
T: FromBuf,
fn extract<T>(&mut self) -> Result<T>where
T: FromBuf,
Read a custom object from a buffer
§Errors
This method will return an error if the number of bytes remaining in the buffer is insufficent, or if the type cannot be parsed from the bytes.
Sourcefn should_be_exhausted(&self) -> Result<(), ExtraneousBytes>
fn should_be_exhausted(&self) -> Result<(), ExtraneousBytes>
Check whether this reader is exhausted (out of bytes).
§Errors
this method will return error::ExtraneousBytes if there are bytes
left in the buffer.
Sourcefn try_get_u8(&mut self) -> Result<u8, Truncated>
fn try_get_u8(&mut self) -> Result<u8, Truncated>
This method wraps Buf::get_u8 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i8(&mut self) -> Result<i8, Truncated>
fn try_get_i8(&mut self) -> Result<i8, Truncated>
This method wraps Buf::get_i8 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u16(&mut self) -> Result<u16, Truncated>
fn try_get_u16(&mut self) -> Result<u16, Truncated>
This method wraps Buf::get_u16 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i16(&mut self) -> Result<i16, Truncated>
fn try_get_i16(&mut self) -> Result<i16, Truncated>
This method wraps Buf::get_i16 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u32(&mut self) -> Result<u32, Truncated>
fn try_get_u32(&mut self) -> Result<u32, Truncated>
This method wraps Buf::get_u32 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i32(&mut self) -> Result<i32, Truncated>
fn try_get_i32(&mut self) -> Result<i32, Truncated>
This method wraps Buf::get_i32 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u64(&mut self) -> Result<u64, Truncated>
fn try_get_u64(&mut self) -> Result<u64, Truncated>
This method wraps Buf::get_u64 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i64(&mut self) -> Result<i64, Truncated>
fn try_get_i64(&mut self) -> Result<i64, Truncated>
This method wraps Buf::get_i64 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u128(&mut self) -> Result<u128, Truncated>
fn try_get_u128(&mut self) -> Result<u128, Truncated>
This method wraps Buf::get_u128 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i128(&mut self) -> Result<i128, Truncated>
fn try_get_i128(&mut self) -> Result<i128, Truncated>
This method wraps Buf::get_i128 with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u16_le(&mut self) -> Result<u16, Truncated>
fn try_get_u16_le(&mut self) -> Result<u16, Truncated>
This method wraps Buf::get_u16_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i16_le(&mut self) -> Result<i16, Truncated>
fn try_get_i16_le(&mut self) -> Result<i16, Truncated>
This method wraps Buf::get_i16_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u32_le(&mut self) -> Result<u32, Truncated>
fn try_get_u32_le(&mut self) -> Result<u32, Truncated>
This method wraps Buf::get_u32_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i32_le(&mut self) -> Result<i32, Truncated>
fn try_get_i32_le(&mut self) -> Result<i32, Truncated>
This method wraps Buf::get_i32_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u64_le(&mut self) -> Result<u64, Truncated>
fn try_get_u64_le(&mut self) -> Result<u64, Truncated>
This method wraps Buf::get_u64_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i64_le(&mut self) -> Result<i64, Truncated>
fn try_get_i64_le(&mut self) -> Result<i64, Truncated>
This method wraps Buf::get_i64_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_u128_le(&mut self) -> Result<u128, Truncated>
fn try_get_u128_le(&mut self) -> Result<u128, Truncated>
This method wraps Buf::get_u128_le with a bounds check to ensure there are enough bytes remaining, without panicking.
Sourcefn try_get_i128_le(&mut self) -> Result<i128, Truncated>
fn try_get_i128_le(&mut self) -> Result<i128, Truncated>
This method wraps Buf::get_i128_le with a bounds check to ensure there are enough bytes remaining, without panicking.
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.