pub trait Reader {
// Required methods
fn read_u8(&mut self) -> Result<u8, Error>;
fn read_u16(&mut self) -> Result<u16, Error>;
fn read_u32(&mut self) -> Result<u32, Error>;
fn read_u64(&mut self) -> Result<u64, Error>;
fn read_i32(&mut self) -> Result<i32, Error>;
fn read_i64(&mut self) -> Result<i64, Error>;
fn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>;
fn read_fixed_bytes(&mut self, length: usize) -> Result<Vec<u8>, Error>;
fn expect_u8(&mut self, val: u8) -> Result<u8, Error>;
fn protocol_version(&self) -> ProtocolVersion;
}Expand description
Implementations defined how different numbers and binary structures are read from an underlying stream or container (depending on implementation).
Required Methods§
Sourcefn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>
fn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>
Read a u64 len prefix followed by that number of exact bytes.
Sourcefn read_fixed_bytes(&mut self, length: usize) -> Result<Vec<u8>, Error>
fn read_fixed_bytes(&mut self, length: usize) -> Result<Vec<u8>, Error>
Read a fixed number of bytes from the underlying reader.
Sourcefn expect_u8(&mut self, val: u8) -> Result<u8, Error>
fn expect_u8(&mut self, val: u8) -> Result<u8, Error>
Consumes a byte from the reader, producing an error if it doesn’t have the expected value
Sourcefn protocol_version(&self) -> ProtocolVersion
fn protocol_version(&self) -> ProtocolVersion
Access to underlying protocol version to support version specific deserialization logic.