Struct BitRecorder

struct BitRecorder<N, E: Endianness> { ... }

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>

fn new() -> Self

Creates new recorder

fn with_capacity(writes: usize) -> Self

Creates new recorder sized for the given number of writes

fn endian(_endian: E) -> Self

Creates new recorder with the given endianness

fn written(self: &Self) -> N

Returns number of bits written

fn playback<W: BitWrite>(self: &Self, writer: &mut W) -> Result<()>

Plays recorded writes to the given writer

impl<N, E> BitWrite for BitRecorder<N, E>

fn write_bit(self: &mut Self, bit: bool) -> Result<()>
fn write<U>(self: &mut Self, bits: u32, value: U) -> Result<()>
where
    U: Numeric
fn write_out<BITS: u32, U>(self: &mut Self, value: U) -> Result<()>
where
    U: Numeric
fn write_signed<S>(self: &mut Self, bits: u32, value: S) -> Result<()>
where
    S: SignedNumeric
fn write_signed_out<BITS: u32, S>(self: &mut Self, value: S) -> Result<()>
where
    S: SignedNumeric
fn write_from<V>(self: &mut Self, value: V) -> Result<()>
where
    V: Primitive
fn write_as_from<F, V>(self: &mut Self, value: V) -> Result<()>
where
    F: Endianness,
    V: Primitive
fn write_unary0(self: &mut Self, value: u32) -> Result<()>
fn write_unary1(self: &mut Self, value: u32) -> Result<()>
fn write_bytes(self: &mut Self, buf: &[u8]) -> Result<()>
fn byte_aligned(self: &Self) -> bool

impl<N, E> Freeze for BitRecorder<N, E>

impl<N, E> HuffmanWrite for BitRecorder<N, E>

fn write_huffman<T>(self: &mut Self, tree: &WriteHuffmanTree<E, T>, symbol: T) -> Result<()>
where
    T: Ord + Copy

impl<N, E> RefUnwindSafe for BitRecorder<N, E>

impl<N, E> Send for BitRecorder<N, E>

impl<N, E> Sync for BitRecorder<N, E>

impl<N, E> Unpin for BitRecorder<N, E>

impl<N, E> UnsafeUnpin for BitRecorder<N, E>

impl<N, E> UnwindSafe for BitRecorder<N, E>

impl<N: $crate::default::Default, E: $crate::default::Default + Endianness> Default for BitRecorder<N, E>

fn default() -> BitRecorder<N, E>

impl<T> Any for BitRecorder<N, E>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for BitRecorder<N, E>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for BitRecorder<N, E>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for BitRecorder<N, E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for BitRecorder<N, E>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for BitRecorder<N, E>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for BitRecorder<N, E>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>