Trait eio::WriteExt [−][src]
pub trait WriteExt<const N: usize>: Write { fn write_array(&mut self, buf: [u8; N]) -> Result<()> { ... } fn write_be<T: ToBytes<N>>(&mut self, t: T) -> Result<()> { ... } fn write_le<T: ToBytes<N>>(&mut self, t: T) -> Result<()> { ... } }
Expand description
Provides extended methods to types that implement std::io::Write
.
Provided methods
fn write_array(&mut self, buf: [u8; N]) -> Result<()>
[src]
Expand description
Write an array of size N
to the destination.
Note: this method is provided for completion sake because it is the
opposite of the ReadExt::read_array
method, but since arrays implement Deref
to slice you can just use
Write::write_all
.
Examples
use eio::WriteExt; let mut w = Vec::new(); w.write_array([0x12, 0x34, 0x56]).unwrap(); assert_eq!(w, &[0x12, 0x34, 0x56]);
fn write_be<T: ToBytes<N>>(&mut self, t: T) -> Result<()>
[src]
Expand description
Write T
to the destination in big endian order.
Examples
use eio::WriteExt; let mut w = Vec::new(); w.write_be(0x12345678).unwrap(); assert_eq!(w, &[0x12, 0x34, 0x56, 0x78]);
fn write_le<T: ToBytes<N>>(&mut self, t: T) -> Result<()>
[src]
Expand description
Write T
to the destination in little endian order.
Examples
use eio::WriteExt; let mut w = Vec::new(); w.write_le(0x12345678).unwrap(); assert_eq!(w, &[0x78, 0x56, 0x34, 0x12]);