Trait BitWrite

Source
pub trait BitWrite<E: Endianness> {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn write_bits(&mut self, value: u64, n: usize) -> Result<usize, Self::Error>;
    fn write_unary(&mut self, value: u64) -> Result<usize, Self::Error>;
    fn flush(&mut self) -> Result<usize, Self::Error>;

    // Provided method
    fn copy_from<F: Endianness, R: BitRead<F>>(
        &mut self,
        bit_read: &mut R,
        n: u64,
    ) -> Result<(), CopyError<R::Error, Self::Error>> { ... }
}
Expand description

Sequential, streaming bit-by-bit writes.

This trait specify basic operation over which codes can be implemented by traits such as crate::codes::GammaWriteParam.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn write_bits(&mut self, value: u64, n: usize) -> Result<usize, Self::Error>

Write the lowest n bits of value to the stream and return the number of bits written, that is, n.

Implementors should check the value of n in test mode and panic if it is greater than 64. Moreover, if the feature checks is enabled they should check that the remaining bits of value are zero.

Source

fn write_unary(&mut self, value: u64) -> Result<usize, Self::Error>

Write value as a unary code to the stream and return the number of bits written, that is, value plus one.

Source

fn flush(&mut self) -> Result<usize, Self::Error>

Flush the buffer, consuming the bit stream.

Returns the number of bits written from the bit buffer (not including padding).

Provided Methods§

Source

fn copy_from<F: Endianness, R: BitRead<F>>( &mut self, bit_read: &mut R, n: u64, ) -> Result<(), CopyError<R::Error, Self::Error>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E: Endianness, BW: BitWrite<E>, const PRINT: bool> BitWrite<E> for CountBitWriter<E, BW, PRINT>

Source§

type Error = <BW as BitWrite<E>>::Error

Source§

impl<E: Endianness, W: BitWrite<E>> BitWrite<E> for DbgBitWriter<E, W>

Source§

type Error = <W as BitWrite<E>>::Error

Source§

impl<WW: WordWrite, WP: WriteParams> BitWrite<BigEndian> for BufBitWriter<BE, WW, WP>
where u64: CastableInto<WW::Word>,

Source§

type Error = <WW as WordWrite>::Error

Source§

impl<WW: WordWrite, WP: WriteParams> BitWrite<LittleEndian> for BufBitWriter<LE, WW, WP>
where u64: CastableInto<WW::Word>,

Source§

type Error = <WW as WordWrite>::Error