Struct BitCounter

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

For counting the number of bits written but generating no output.

Example

use bitstream_io::{BigEndian, BitWrite, BitCounter};
let mut writer: BitCounter<u32, BigEndian> = BitCounter::new();
writer.write(1, 0b1).unwrap();
writer.write(2, 0b01).unwrap();
writer.write(5, 0b10111).unwrap();
assert_eq!(writer.written(), 8);

Implementations

impl<N: Default + Copy, E: Endianness> BitCounter<N, E>

fn new() -> Self

Creates new counter

fn written(self: &Self) -> N

Returns number of bits written

impl<N, E> BitWrite for BitCounter<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_unary1(self: &mut Self, value: u32) -> Result<()>
fn write_unary0(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 BitCounter<N, E>

impl<N, E> HuffmanWrite for BitCounter<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 BitCounter<N, E>

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

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

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

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

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

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

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

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

fn type_id(self: &Self) -> TypeId

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

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

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

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

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

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for BitCounter<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 BitCounter<N, E>

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

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

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