lebe::io

Trait ReadEndian

source
pub trait ReadEndian<T: ?Sized> {
    // Required methods
    fn read_from_little_endian_into(&mut self, value: &mut T) -> Result<()>;
    fn read_from_big_endian_into(&mut self, value: &mut T) -> Result<()>;

    // Provided methods
    fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> { ... }
    fn read_from_little_endian(&mut self) -> Result<T>
       where T: Sized + Default { ... }
    fn read_from_big_endian(&mut self) -> Result<T>
       where T: Sized + Default { ... }
    fn read_from_native_endian(&mut self) -> Result<T>
       where T: Sized + Default { ... }
}
Expand description

A std::io::Read input stream which supports reading any primitive values from bytes. Will decode the values from either little endian or big endian, as desired.

This extension trait is implemented for all Read types. Add use lebe::io::ReadEndian; to your code to automatically unlock this functionality for all types that implement Read.

Required Methods§

source

fn read_from_little_endian_into(&mut self, value: &mut T) -> Result<()>

Read into the supplied reference. Acts the same as std::io::Read::read_exact.

source

fn read_from_big_endian_into(&mut self, value: &mut T) -> Result<()>

Read into the supplied reference. Acts the same as std::io::Read::read_exact.

Provided Methods§

source

fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()>

Read into the supplied reference. Acts the same as std::io::Read::read_exact.

source

fn read_from_little_endian(&mut self) -> Result<T>
where T: Sized + Default,

Read the byte value of the inferred type

source

fn read_from_big_endian(&mut self) -> Result<T>
where T: Sized + Default,

Read the byte value of the inferred type

source

fn read_from_native_endian(&mut self) -> Result<T>
where T: Sized + Default,

Read the byte value of the inferred type

Implementors§

source§

impl<R: Read> ReadEndian<f32> for R

source§

impl<R: Read> ReadEndian<f64> for R

source§

impl<R: Read> ReadEndian<i8> for R

source§

impl<R: Read> ReadEndian<i16> for R

source§

impl<R: Read> ReadEndian<i32> for R

source§

impl<R: Read> ReadEndian<i64> for R

source§

impl<R: Read> ReadEndian<i128> for R

source§

impl<R: Read> ReadEndian<u8> for R

source§

impl<R: Read> ReadEndian<u16> for R

source§

impl<R: Read> ReadEndian<u32> for R

source§

impl<R: Read> ReadEndian<u64> for R

source§

impl<R: Read> ReadEndian<u128> for R

source§

impl<R: Read> ReadEndian<[f32]> for R

source§

impl<R: Read> ReadEndian<[f64]> for R

source§

impl<R: Read> ReadEndian<[i8]> for R

source§

impl<R: Read> ReadEndian<[i16]> for R

source§

impl<R: Read> ReadEndian<[i32]> for R

source§

impl<R: Read> ReadEndian<[i64]> for R

source§

impl<R: Read> ReadEndian<[i128]> for R

source§

impl<R: Read> ReadEndian<[u8]> for R

source§

impl<R: Read> ReadEndian<[u16]> for R

source§

impl<R: Read> ReadEndian<[u32]> for R

source§

impl<R: Read> ReadEndian<[u64]> for R

source§

impl<R: Read> ReadEndian<[u128]> for R