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, write::Writable};

/// An extension to the [`io::Write`] trait.
pub trait WriteExt: io::Write {
    /// Writes `W` with the specified endian.
    fn write_type<W: Writable>(&mut self, value: &W, endian: Endian) -> io::Result<()>;
}

impl<T: io::Write> WriteExt for T {
    #[inline]
    fn write_type<W: Writable>(&mut self, value: &W, endian: Endian) -> io::Result<()> {
        value.write(self, endian)
    }
}