Struct bitstream_io::write::BitCounter
source · pub struct BitCounter<N, E: Endianness> { /* private fields */ }
Expand description
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
sourceimpl<N: Default + Copy, E: Endianness> BitCounter<N, E>
impl<N: Default + Copy, E: Endianness> BitCounter<N, E>
Trait Implementations
sourceimpl<N, E> BitWrite for BitCounter<N, E>where
E: Endianness,
N: Copy + AddAssign + From<u32> + Rem<Output = N> + PartialEq,
impl<N, E> BitWrite for BitCounter<N, E>where
E: Endianness,
N: Copy + AddAssign + From<u32> + Rem<Output = N> + PartialEq,
sourcefn write<U>(&mut self, bits: u32, value: U) -> Result<()>where
U: Numeric,
fn write<U>(&mut self, bits: u32, value: U) -> Result<()>where
U: Numeric,
Writes an unsigned value to the stream using the given
number of bits. Read more
sourcefn write_signed<S>(&mut self, bits: u32, value: S) -> Result<()>where
S: SignedNumeric,
fn write_signed<S>(&mut self, bits: u32, value: S) -> Result<()>where
S: SignedNumeric,
Writes a twos-complement signed value to the stream
with the given number of bits. Read more
sourcefn write_unary1(&mut self, value: u32) -> Result<()>
fn write_unary1(&mut self, value: u32) -> Result<()>
Writes
value
number of 0 bits to the stream
and then writes a 1 bit. This field is variably-sized. Read moresourcefn write_unary0(&mut self, value: u32) -> Result<()>
fn write_unary0(&mut self, value: u32) -> Result<()>
Writes
value
number of 1 bits to the stream
and then writes a 0 bit. This field is variably-sized. Read moresourcefn write_bytes(&mut self, buf: &[u8]) -> Result<()>
fn write_bytes(&mut self, buf: &[u8]) -> Result<()>
Writes the entirety of a byte buffer to the stream. Read more
sourcefn byte_aligned(&self) -> bool
fn byte_aligned(&self) -> bool
Returns true if the stream is aligned at a whole byte.
sourcefn byte_align(&mut self) -> Result<()>
fn byte_align(&mut self) -> Result<()>
Pads the stream with 0 bits until it is aligned at a whole byte.
Does nothing if the stream is already aligned. Read more
sourceimpl<N: Default, E: Default + Endianness> Default for BitCounter<N, E>
impl<N: Default, E: Default + Endianness> Default for BitCounter<N, E>
sourcefn default() -> BitCounter<N, E>
fn default() -> BitCounter<N, E>
Returns the “default value” for a type. Read more
sourceimpl<N, E> HuffmanWrite<E> for BitCounter<N, E>where
E: Endianness,
N: AddAssign + From<u32>,
impl<N, E> HuffmanWrite<E> for BitCounter<N, E>where
E: Endianness,
N: AddAssign + From<u32>,
sourcefn write_huffman<T>(
&mut self,
tree: &WriteHuffmanTree<E, T>,
symbol: T
) -> Result<()>where
T: Ord + Copy,
fn write_huffman<T>(
&mut self,
tree: &WriteHuffmanTree<E, T>,
symbol: T
) -> Result<()>where
T: Ord + Copy,
Writes Huffman code for the given symbol to the stream. Read more
Auto Trait Implementations
impl<N, E> RefUnwindSafe for BitCounter<N, E>where
E: RefUnwindSafe,
N: RefUnwindSafe,
impl<N, E> Send for BitCounter<N, E>where
E: Send,
N: Send,
impl<N, E> Sync for BitCounter<N, E>where
E: Sync,
N: Sync,
impl<N, E> Unpin for BitCounter<N, E>where
E: Unpin,
N: Unpin,
impl<N, E> UnwindSafe for BitCounter<N, E>where
E: UnwindSafe,
N: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more