Skip to main content

BufReader

Trait BufReader 

Source
pub trait BufReader<'de> {
Show 17 methods // Required methods fn get_chunk(&mut self, size: usize) -> Option<&'de [u8]>; fn remaining(&self) -> usize; // Provided methods fn get_array_chunk<const N: usize>(&mut self) -> Option<&'de [u8; N]> { ... } fn get_slice(&mut self, size: usize) -> Result<&'de [u8], DecodeError> { ... } fn get_array<const N: usize>(&mut self) -> Result<&'de [u8; N], DecodeError> { ... } fn get_u8(&mut self) -> Result<u8, DecodeError> { ... } fn get_u16(&mut self) -> Result<u16, DecodeError> { ... } fn get_u32(&mut self) -> Result<u32, DecodeError> { ... } fn get_u64(&mut self) -> Result<u64, DecodeError> { ... } fn get_u128(&mut self) -> Result<u128, DecodeError> { ... } fn get_u256(&mut self) -> Result<U256, DecodeError> { ... } fn get_i8(&mut self) -> Result<i8, DecodeError> { ... } fn get_i16(&mut self) -> Result<i16, DecodeError> { ... } fn get_i32(&mut self) -> Result<i32, DecodeError> { ... } fn get_i64(&mut self) -> Result<i64, DecodeError> { ... } fn get_i128(&mut self) -> Result<i128, DecodeError> { ... } fn get_i256(&mut self) -> Result<I256, DecodeError> { ... }
}
Expand description

A buffered reader of some kind.

The lifetime 'de allows the output of deserialization to borrow from the input.

Required Methods§

Source

fn get_chunk(&mut self, size: usize) -> Option<&'de [u8]>

Reads and returns a chunk of .len() = size advancing the cursor iff self.remaining() >= size.

Source

fn remaining(&self) -> usize

Returns the number of bytes left to read in the input.

Provided Methods§

Source

fn get_array_chunk<const N: usize>(&mut self) -> Option<&'de [u8; N]>

Reads and returns a chunk of .len() = N as an array, advancing the cursor.

Source

fn get_slice(&mut self, size: usize) -> Result<&'de [u8], DecodeError>

Reads and returns a byte slice of .len() = size advancing the cursor.

Source

fn get_array<const N: usize>(&mut self) -> Result<&'de [u8; N], DecodeError>

Reads an array of type [u8; N] from the input.

Source

fn get_u8(&mut self) -> Result<u8, DecodeError>

Reads a u8 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_u16(&mut self) -> Result<u16, DecodeError>

Reads a u16 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_u32(&mut self) -> Result<u32, DecodeError>

Reads a u32 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_u64(&mut self) -> Result<u64, DecodeError>

Reads a u64 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_u128(&mut self) -> Result<u128, DecodeError>

Reads a u128 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_u256(&mut self) -> Result<U256, DecodeError>

Reads a u256 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i8(&mut self) -> Result<i8, DecodeError>

Reads an i8 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i16(&mut self) -> Result<i16, DecodeError>

Reads an i16 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i32(&mut self) -> Result<i32, DecodeError>

Reads an i32 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i64(&mut self) -> Result<i64, DecodeError>

Reads an i64 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i128(&mut self) -> Result<i128, DecodeError>

Reads an i128 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Source

fn get_i256(&mut self) -> Result<I256, DecodeError>

Reads an i256 in little endian (LE) encoding from the input.

This method is provided for convenience and is derived from get_chunk’s definition.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'de> BufReader<'de> for &'de [u8]

Source§

fn get_chunk(&mut self, size: usize) -> Option<&'de [u8]>

Source§

fn get_array_chunk<const N: usize>(&mut self) -> Option<&'de [u8; N]>

Source§

fn remaining(&self) -> usize

Implementors§

Source§

impl<'de, I> BufReader<'de> for &'de Cursor<I>
where I: AsRef<[u8]>,