rw-types 0.1.0

Library for reading and writing types.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io;

use crate::{Endian, read::Readable};

/// An extension to the [`io::Read`] trait.
pub trait ReadExt: io::Read {
    /// Reads `R` with the specified endian.
    fn read_type<R: Readable>(&mut self, endian: Endian) -> io::Result<R>;
}

impl<T: io::Read> ReadExt for T {
    #[inline]
    fn read_type<R: Readable>(&mut self, endian: Endian) -> io::Result<R> {
        R::read(self, endian)
    }
}