pub trait ByteWrite {
    fn write<N: Numeric>(&mut self, value: N) -> Result<()>;
    fn write_bytes(&mut self, buf: &[u8]) -> Result<()>;
}
Expand description

A trait for anything that can write aligned values to an output stream

Required Methods

Writes whole numeric value to stream

Errors

Passes along any I/O error from the underlying stream.

Examples
use std::io::Write;
use bitstream_io::{BigEndian, ByteWriter, ByteWrite};
let mut writer = ByteWriter::endian(Vec::new(), BigEndian);
writer.write(0b0000000011111111u16).unwrap();
assert_eq!(writer.into_writer(), [0b00000000, 0b11111111]);
use std::io::Write;
use bitstream_io::{LittleEndian, ByteWriter, ByteWrite};
let mut writer = ByteWriter::endian(Vec::new(), LittleEndian);
writer.write(0b0000000011111111u16).unwrap();
assert_eq!(writer.into_writer(), [0b11111111, 0b00000000]);

Writes the entirety of a byte buffer to the stream.

Errors

Passes along any I/O error from the underlying stream.

Implementors