pub trait ReadBytes {
type Error;
// Required methods
fn read_u64(&mut self) -> Result<u64, Self::Error>;
fn read_i64(&mut self) -> Result<i64, Self::Error>;
fn read_u32(&mut self) -> Result<u32, Self::Error>;
fn read_i32(&mut self) -> Result<i32, Self::Error>;
fn read_u16(&mut self) -> Result<u16, Self::Error>;
fn read_i16(&mut self) -> Result<i16, Self::Error>;
fn read_bool(&mut self) -> Result<bool, Self::Error>;
fn read_u8(&mut self) -> Result<u8, Self::Error>;
fn read_i8(&mut self) -> Result<i8, Self::Error>;
fn read_bytes<const N: usize>(&mut self) -> Result<[u8; N], Self::Error>;
fn skip(&mut self, bytes_to_skip: usize);
}
Required Associated Types§
Required Methods§
Sourcefn read_u64(&mut self) -> Result<u64, Self::Error>
fn read_u64(&mut self) -> Result<u64, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 8]
is within bounds of the bytes
slice.
Sourcefn read_i64(&mut self) -> Result<i64, Self::Error>
fn read_i64(&mut self) -> Result<i64, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 8]
is within bounds of the bytes
slice.
Sourcefn read_u32(&mut self) -> Result<u32, Self::Error>
fn read_u32(&mut self) -> Result<u32, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 4]
is within bounds of the bytes
slice.
Sourcefn read_i32(&mut self) -> Result<i32, Self::Error>
fn read_i32(&mut self) -> Result<i32, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 4]
is within bounds of the bytes
slice.
Sourcefn read_u16(&mut self) -> Result<u16, Self::Error>
fn read_u16(&mut self) -> Result<u16, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 2]
is within bounds of the bytes
slice.
Sourcefn read_i16(&mut self) -> Result<i16, Self::Error>
fn read_i16(&mut self) -> Result<i16, Self::Error>
§Safety
The caller is responsible for ensuring that the range [self.offset..self.offset + 2]
is within bounds of the bytes
slice.
Sourcefn read_bool(&mut self) -> Result<bool, Self::Error>
fn read_bool(&mut self) -> Result<bool, Self::Error>
§Safety
This function returns an error instead of panicking if the index is out of bounds. Valid values are 0 (false) and 1 (true). Any other value results in an error.
Sourcefn read_u8(&mut self) -> Result<u8, Self::Error>
fn read_u8(&mut self) -> Result<u8, Self::Error>
§Safety
This function returns an error instead of panicking if the index is out of bounds.
Sourcefn read_i8(&mut self) -> Result<i8, Self::Error>
fn read_i8(&mut self) -> Result<i8, Self::Error>
§Safety
This function returns an error instead of panicking if the index is out of bounds.
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.