Trait lebe::io::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§
sourcefn read_from_little_endian(read: &mut R) -> Result<Self>
fn read_from_little_endian(read: &mut R) -> Result<Self>
Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian()
.
sourcefn read_from_big_endian(read: &mut R) -> Result<Self>
fn read_from_big_endian(read: &mut R) -> Result<Self>
Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian()
.
sourcefn read_from_native_endian(read: &mut R) -> Result<Self>
fn read_from_native_endian(read: &mut R) -> Result<Self>
Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian()
.