[][src]Trait endio::ERead

pub trait ERead<E: Endianness>: Sized {
    fn read<D: Deserialize<E, Self>>(&mut self) -> Res<D> { ... }
fn read_be<D: Deserialize<BigEndian, Self>>(&mut self) -> Res<D> { ... }
fn read_le<D: Deserialize<LittleEndian, Self>>(&mut self) -> Res<D> { ... } }

Only necessary for custom (de-)serializations.

Interface for reading data with a specified endianness. Use this interface to make deserializations automatically switch endianness without having to write the same code twice.

In theory this would be the only write trait and BE-/LERead would be aliases to the BE/LE type parameter variants, but for some reason that doesn't import methods in use notation.

Examples

use endio::LERead;

let mut reader = &b"\x2a\x01\xcf\xfe\xf3\x2c"[..];
let a: u8 = reader.read().unwrap();
let b: bool = reader.read().unwrap();
let c: u32 = reader.read().unwrap();
assert_eq!(a, 42);
assert_eq!(b, true);
assert_eq!(c, 754187983);

Provided methods

fn read<D: Deserialize<E, Self>>(&mut self) -> Res<D>

Reads a Deserialize from the reader, in the reader's endianness.

What's actually read is up to the implementation of the Deserialize.

fn read_be<D: Deserialize<BigEndian, Self>>(&mut self) -> Res<D>

Reads in forced big endian.

fn read_le<D: Deserialize<LittleEndian, Self>>(&mut self) -> Res<D>

Reads in forced little endian.

Loading content...

Implementors

impl<R: Read, E: Endianness> ERead<E> for R[src]

fn read<D: Deserialize<E, Self>>(&mut self) -> Res<D>[src]

fn read_be<D: Deserialize<BigEndian, Self>>(&mut self) -> Res<D>[src]

fn read_le<D: Deserialize<LittleEndian, Self>>(&mut self) -> Res<D>[src]

Loading content...