[−][src]Struct bitstream_io::write::BitRecorder
For recording writes in order to play them back on another writer
Example
use std::io::Write; use bitstream_io::{BigEndian, BitWriter, BitWrite, BitRecorder}; let mut recorder: BitRecorder<u32, BigEndian> = BitRecorder::new(); recorder.write(1, 0b1).unwrap(); recorder.write(2, 0b01).unwrap(); recorder.write(5, 0b10111).unwrap(); assert_eq!(recorder.written(), 8); let mut writer = BitWriter::endian(Vec::new(), BigEndian); recorder.playback(&mut writer); assert_eq!(writer.into_writer(), [0b10110111]);
Implementations
impl<N: Default + Copy, E: Endianness> BitRecorder<N, E>[src]
pub fn new() -> Self[src]
Creates new recorder
pub fn with_capacity(writes: usize) -> Self[src]
Creates new recorder sized for the given number of writes
pub fn endian(_endian: E) -> Self[src]
Creates new recorder with the given endiannness
pub fn written(&self) -> N[src]
Returns number of bits written
pub fn playback<W: BitWrite>(&self, writer: &mut W) -> Result<()>[src]
Plays recorded writes to the given writer
Trait Implementations
impl<N, E> BitWrite for BitRecorder<N, E> where
E: Endianness,
N: Copy + From<u32> + AddAssign + Rem<Output = N> + Eq, [src]
E: Endianness,
N: Copy + From<u32> + AddAssign + Rem<Output = N> + Eq,
pub fn write_bit(&mut self, bit: bool) -> Result<()>[src]
pub fn write<U>(&mut self, bits: u32, value: U) -> Result<()> where
U: Numeric, [src]
U: Numeric,
pub fn write_signed<S>(&mut self, bits: u32, value: S) -> Result<()> where
S: SignedNumeric, [src]
S: SignedNumeric,
pub fn write_unary0(&mut self, value: u32) -> Result<()>[src]
pub fn write_unary1(&mut self, value: u32) -> Result<()>[src]
pub fn write_bytes(&mut self, buf: &[u8]) -> Result<()>[src]
pub fn byte_aligned(&self) -> bool[src]
pub fn byte_align(&mut self) -> Result<()>[src]
impl<N: Default, E: Default + Endianness> Default for BitRecorder<N, E>[src]
pub fn default() -> BitRecorder<N, E>[src]
impl<N, E> HuffmanWrite<E> for BitRecorder<N, E> where
E: Endianness,
N: Copy + From<u32> + AddAssign + Rem<Output = N> + Eq, [src]
E: Endianness,
N: Copy + From<u32> + AddAssign + Rem<Output = N> + Eq,
pub fn write_huffman<T>(
&mut self,
tree: &WriteHuffmanTree<E, T>,
symbol: T
) -> Result<()> where
T: Ord + Copy, [src]
&mut self,
tree: &WriteHuffmanTree<E, T>,
symbol: T
) -> Result<()> where
T: Ord + Copy,
Auto Trait Implementations
impl<N, E> RefUnwindSafe for BitRecorder<N, E> where
E: RefUnwindSafe,
N: RefUnwindSafe, [src]
E: RefUnwindSafe,
N: RefUnwindSafe,
impl<N, E> Send for BitRecorder<N, E> where
E: Send,
N: Send, [src]
E: Send,
N: Send,
impl<N, E> Sync for BitRecorder<N, E> where
E: Sync,
N: Sync, [src]
E: Sync,
N: Sync,
impl<N, E> Unpin for BitRecorder<N, E> where
E: Unpin,
N: Unpin, [src]
E: Unpin,
N: Unpin,
impl<N, E> UnwindSafe for BitRecorder<N, E> where
E: UnwindSafe,
N: UnwindSafe, [src]
E: UnwindSafe,
N: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,