lebe::io

Trait ReadPrimitive

source
pub trait ReadPrimitive<R: Read + ReadEndian<Self>>: Sized + Default {
    // Provided methods
    fn read_from_little_endian(read: &mut R) -> Result<Self> { ... }
    fn read_from_big_endian(read: &mut R) -> Result<Self> { ... }
    fn read_from_native_endian(read: &mut R) -> Result<Self> { ... }
}
Expand description

Offers a prettier versions of reading a primitive number.

The default way of reading a value is:


let number: u16 = reader.read_from_little_endian()?;
println!("{}", number);

This trait enables you to use expressions:


println!("{}", u16::read_from_little_endian(&mut reader)?);

.

Provided Methods§

source

fn read_from_little_endian(read: &mut R) -> Result<Self>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().

source

fn read_from_big_endian(read: &mut R) -> Result<Self>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().

source

fn read_from_native_endian(read: &mut R) -> Result<Self>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<R: Read + ReadEndian<P>, P: Default> ReadPrimitive<R> for P