pub struct BufBitWriter<E: Endianness, WW: WordWrite, WP: WriteParams = DefaultWriteParams> { /* private fields */ }
Expand description

An implementation of BitWrite for a WordWrite.

This implementation uses a bit buffer to store bits that are not yet written. The size of the bit buffer is the size of the word used by the WordWrite, which on most platform should be usize.

The additional type parameter WP is used to select the parameters for the instantanous codes, but the casual user should be happy with the default value. See WriteParams for more details.

Implementations§

source§

impl<E: Endianness, WW: WordWrite, WP: WriteParams> BufBitWriter<E, WW, WP>
where BufBitWriter<E, WW, WP>: BitWrite<E>,

source

pub fn new(backend: WW) -> Self

Create a new BufBitWriter around a WordWrite.

§Example
use dsi_bitstream::prelude::*;
let buffer = Vec::<usize>::new();
let word_writer = MemWordWriterVec::new(buffer);
let mut buf_bit_writer = <BufBitWriter<BE, _>>::new(word_writer);
source

pub fn into_inner(self) -> Result<WW, <Self as BitWrite<E>>::Error>

Return the backend, consuming this writer after flushing it.

Trait Implementations§

source§

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

§

type Error = <WW as WordWrite>::Error

source§

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

Flush the buffer, consuming the bit stream.
source§

fn write_bits( &mut self, value: u64, n_bits: 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. Read more
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 copy_from<F: Endianness>( &mut self, bit_read: &mut impl BitRead<F>, n: u64 ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

source§

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

§

type Error = <WW as WordWrite>::Error

source§

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

Flush the buffer, consuming the bit stream.
source§

fn write_bits( &mut self, value: u64, n_bits: 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. Read more
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 copy_from<F: Endianness>( &mut self, bit_read: &mut impl BitRead<F>, n: u64 ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

source§

impl<E: Debug + Endianness, WW: Debug + WordWrite, WP: Debug + WriteParams> Debug for BufBitWriter<E, WW, WP>
where WW::Word: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<WR: WordWrite, DC: WriteParams> DeltaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
where u64: CastableInto<WR::Word>,

source§

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

source§

impl<WR: WordWrite, DC: WriteParams> DeltaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
where u64: CastableInto<WR::Word>,

source§

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

source§

impl<E: Endianness, WW: WordWrite, WP: WriteParams> Drop for BufBitWriter<E, WW, WP>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<WR: WordWrite> GammaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DefaultWriteParams>
where u64: CastableInto<WR::Word>,

source§

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

source§

impl<WR: WordWrite> GammaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DefaultWriteParams>
where u64: CastableInto<WR::Word>,

source§

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

source§

impl<WR: WordWrite, DC: WriteParams> ZetaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
where u64: CastableInto<WR::Word>,

source§

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

source§

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

source§

impl<WR: WordWrite, DC: WriteParams> ZetaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
where u64: CastableInto<WR::Word>,

source§

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

source§

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

Auto Trait Implementations§

§

impl<E, WW, WP> RefUnwindSafe for BufBitWriter<E, WW, WP>

§

impl<E, WW, WP> Send for BufBitWriter<E, WW, WP>
where E: Send, WP: Send, WW: Send,

§

impl<E, WW, WP> Sync for BufBitWriter<E, WW, WP>
where E: Sync, WP: Sync, WW: Sync,

§

impl<E, WW, WP> Unpin for BufBitWriter<E, WW, WP>
where E: Unpin, WP: Unpin, WW: Unpin, <WW as WordWrite>::Word: Unpin,

§

impl<E, WW, WP> UnwindSafe for BufBitWriter<E, WW, WP>
where E: UnwindSafe, WP: UnwindSafe, WW: UnwindSafe, <WW as WordWrite>::Word: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CastableFrom<T> for T

source§

fn cast_from(value: T) -> T

Call Self as W
source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

source§

fn cast(self) -> U

Call W::cast_from(self)
source§

impl<B> DeltaWriteParam<BigEndian> for B

source§

fn write_delta_param<const USE_DELTA_TABLE: bool, const USE_GAMMA_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<BigEndian>>::Error>

source§

impl<B> DeltaWriteParam<LittleEndian> for B

source§

fn write_delta_param<const USE_DELTA_TABLE: bool, const USE_GAMMA_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<LittleEndian>>::Error>

source§

impl<T> DowncastableFrom<T> for T

source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

source§

fn downcast(self) -> U

Call W::downcast_from(self)
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<B> GammaWriteParam<BigEndian> for B
where B: BitWrite<BigEndian>,

source§

fn write_gamma_param<const USE_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<BigEndian>>::Error>

source§

impl<B> GammaWriteParam<LittleEndian> for B

source§

fn write_gamma_param<const USE_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<LittleEndian>>::Error>

source§

impl<E, B> GolombWrite<E> for B
where E: Endianness, B: BitWrite<E>,

source§

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

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<E, B> MinimalBinaryWrite<E> for B
where E: Endianness, B: BitWrite<E>,

source§

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

source§

impl<E, B> RiceWrite<E> for B
where E: Endianness, B: BitWrite<E>,

source§

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

source§

impl<T> Splat<T> for T

source§

fn splat(value: T) -> T

source§

impl<T> To<T> for T

source§

fn to(self) -> T

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T> UpcastableFrom<T> for T

source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

source§

fn upcast(self) -> U

Call W::upcast_from(self)
source§

impl<B> ZetaWriteParam<BigEndian> for B
where B: BitWrite<BigEndian>,

source§

fn write_zeta_param<const USE_TABLE: bool>( &mut self, n: u64, k: u64 ) -> Result<usize, <B as BitWrite<BigEndian>>::Error>

source§

fn write_zeta3_param<const USE_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<BigEndian>>::Error>

source§

impl<B> ZetaWriteParam<LittleEndian> for B

source§

fn write_zeta_param<const USE_TABLE: bool>( &mut self, n: u64, k: u64 ) -> Result<usize, <B as BitWrite<LittleEndian>>::Error>

source§

fn write_zeta3_param<const USE_TABLE: bool>( &mut self, n: u64 ) -> Result<usize, <B as BitWrite<LittleEndian>>::Error>