BitWriter

Trait BitWriter 

Source
pub trait BitWriter {
    type Error: Error;

    // Required methods
    fn capacity_left(&self) -> usize;
    fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>;

    // Provided methods
    fn write_bitslice(
        &mut self,
        bits: &BitSlice<u8, Msb0>,
    ) -> Result<(), Self::Error> { ... }
    fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error> { ... }
}
Expand description

Bitwise writer.

Required Associated Types§

Required Methods§

Source

fn capacity_left(&self) -> usize

Returns remaining capacity in bits

Source

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Writes a single bit.

Provided Methods§

Source

fn write_bitslice( &mut self, bits: &BitSlice<u8, Msb0>, ) -> Result<(), Self::Error>

Writes given bitslice.
Might be optimized by the implementation.

Source

fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error>

Writes given bit exactly n times.
Might be optimized by the implementation.

Implementations on Foreign Types§

Source§

impl BitWriter for &mut BitSlice<u8, Msb0>

Source§

type Error = StringError

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

fn write_bitslice( &mut self, bits: &BitSlice<u8, Msb0>, ) -> Result<(), Self::Error>

Source§

fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error>

Source§

impl BitWriter for String

Binary string, e.g. "0010110...."

Source§

type Error = StringError

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

impl BitWriter for Vec<bool>

Source§

type Error = StringError

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

impl<S> BitWriter for BitVec<S, Msb0>
where S: BitStore,

Source§

type Error = StringError

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

fn write_bitslice( &mut self, bits: &BitSlice<u8, Msb0>, ) -> Result<(), Self::Error>

Source§

fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error>

Source§

impl<W: BitWriter + ?Sized> BitWriter for &mut W

Source§

type Error = <W as BitWriter>::Error

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

fn write_bitslice( &mut self, bits: &BitSlice<u8, Msb0>, ) -> Result<(), Self::Error>

Source§

fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error>

Source§

impl<W: BitWriter + ?Sized> BitWriter for Box<W>

Source§

type Error = <W as BitWriter>::Error

Source§

fn capacity_left(&self) -> usize

Source§

fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>

Source§

fn write_bitslice( &mut self, bits: &BitSlice<u8, Msb0>, ) -> Result<(), Self::Error>

Source§

fn repeat_bit(&mut self, n: usize, bit: bool) -> Result<(), Self::Error>

Implementors§

Source§

impl BitWriter for NoopBitWriter

Source§

impl<T, W> BitWriter for Tee<T, W>
where T: BitWriter, W: BitWriter,

Source§

impl<W> BitWriter for BitCounter<W>
where W: BitWriter,

Source§

impl<W> BitWriter for Io<W>
where W: Write,

Source§

impl<W> BitWriter for LimitWriter<W>
where W: BitWriter,