Skip to main content

rw_types/read/
ext.rs

1use std::io;
2
3use crate::{Endian, read::Readable};
4
5/// An extension to the [`io::Read`] trait.
6pub trait ReadExt: io::Read {
7    /// Reads `R` with the specified endian.
8    fn read_type<R: Readable>(&mut self, endian: Endian) -> io::Result<R>;
9}
10
11impl<T: io::Read> ReadExt for T {
12    #[inline]
13    fn read_type<R: Readable>(&mut self, endian: Endian) -> io::Result<R> {
14        R::read(self, endian)
15    }
16}