[][src]Struct bitstream_io::write::BitRecorder

pub struct BitRecorder<N, E: Endianness> { /* fields omitted */ }

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]

impl<N: Default, E: Default + Endianness> Default for 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]

Auto Trait Implementations

impl<N, E> RefUnwindSafe for BitRecorder<N, E> where
    E: RefUnwindSafe,
    N: RefUnwindSafe
[src]

impl<N, E> Send for BitRecorder<N, E> where
    E: Send,
    N: Send
[src]

impl<N, E> Sync for BitRecorder<N, E> where
    E: Sync,
    N: Sync
[src]

impl<N, E> Unpin for BitRecorder<N, E> where
    E: Unpin,
    N: Unpin
[src]

impl<N, E> UnwindSafe for BitRecorder<N, E> where
    E: UnwindSafe,
    N: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.