Skip to main content

ReadPrimitive

Trait ReadPrimitive 

Source
pub trait ReadPrimitive {
Show 15 methods // Required methods 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_u128(&mut self) -> Result<u128, Error>; fn read_usize(&mut self) -> Result<usize, Error>; fn read_i16(&mut self) -> Result<i16, Error>; fn read_i32(&mut self) -> Result<i32, Error>; fn read_i64(&mut self) -> Result<i64, Error>; fn read_i128(&mut self) -> Result<i128, Error>; fn read_isize(&mut self) -> Result<isize, Error>; fn read_f32(&mut self) -> Result<f32, Error>; fn read_f64(&mut self) -> Result<f64, Error>; fn read_u8(&mut self) -> Result<u8, Error>; fn read_i8(&mut self) -> Result<i8, Error>; fn read_bool_byte(&mut self) -> Result<bool, Error>;
}
Expand description

A trait that provides methods for reading primitive types with configurable endianness support.

Primitive values with multi-byte representations are interpreted according to the configured Endian setting of the reader. Most fixed-width primitives have a stable representation when an explicit endianness is used.

Note: Platform-dependent types such as usize and isize use the native size of the target architecture and are therefore not portable between different platforms. Similarly, [Endian::Native] should only be used when the serialized data is intended for use on the same architecture.

Required Methods§

Source

fn read_u16(&mut self) -> Result<u16, Error>

Reads a u16 using the reader’s configured endianness.

Source

fn read_u32(&mut self) -> Result<u32, Error>

Reads a u32 using the reader’s configured endianness.

Source

fn read_u64(&mut self) -> Result<u64, Error>

Reads a u64 using the reader’s configured endianness.

Source

fn read_u128(&mut self) -> Result<u128, Error>

Reads a u128 using the reader’s configured endianness.

Source

fn read_usize(&mut self) -> Result<usize, Error>

Reads a usize using the reader’s configured endianness.

Source

fn read_i16(&mut self) -> Result<i16, Error>

Reads a i16 using the reader’s configured endianness.

Source

fn read_i32(&mut self) -> Result<i32, Error>

Reads a i32 using the reader’s configured endianness.

Source

fn read_i64(&mut self) -> Result<i64, Error>

Reads a i64 using the reader’s configured endianness.

Source

fn read_i128(&mut self) -> Result<i128, Error>

Reads a i128 using the reader’s configured endianness.

Source

fn read_isize(&mut self) -> Result<isize, Error>

Reads a isize using the reader’s configured endianness.

Source

fn read_f32(&mut self) -> Result<f32, Error>

Reads a f32 using the reader’s configured endianness.

Source

fn read_f64(&mut self) -> Result<f64, Error>

Reads a f64 using the reader’s configured endianness.

Source

fn read_u8(&mut self) -> Result<u8, Error>

Reads a raw u8 byte value (endianness is not applied).

Source

fn read_i8(&mut self) -> Result<i8, Error>

Reads a raw i8 byte value (endianness is not applied).

Source

fn read_bool_byte(&mut self) -> Result<bool, Error>

Reads a bool from the reader, where 0 represents false and any non-zero value represents true.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<'a, Ctx> ReadPrimitive for Reader<'a, Ctx>