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<usize, Self::Error>

Flush the buffer, consuming the bit stream. Read more
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, R: BitRead<F>>( &mut self, bit_read: &mut R, n: u64 ) -> Result<(), CopyError<R::Error, Self::Error>>

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<usize, Self::Error>

Flush the buffer, consuming the bit stream. Read more
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, R: BitRead<F>>( &mut self, bit_read: &mut R, n: u64 ) -> Result<(), CopyError<R::Error, Self::Error>>

source§

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

§

type Copy = False

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<E: Endianness, WW, WP: WriteParams> MemDbgImpl for BufBitWriter<E, WW, WP>

source§

fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags ) -> Result

source§

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

source§

fn mem_size(&self, _memsize_flags: SizeFlags) -> usize

Return the (recursively computed) overall memory size of the structure in bytes.
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> Freeze for BufBitWriter<E, WW, WP>
where E: Endianness + 'static, WW: Freeze, <WW as WordWrite>::Word: Freeze,

§

impl<E, WW, WP> RefUnwindSafe for BufBitWriter<E, WW, WP>
where E: Endianness + 'static + RefUnwindSafe, WW: RefUnwindSafe, <WW as WordWrite>::Word: RefUnwindSafe, WP: RefUnwindSafe,

§

impl<E, WW, WP> Send for BufBitWriter<E, WW, WP>
where E: Endianness + 'static + Send, WW: Send, WP: Send,

§

impl<E, WW, WP> Sync for BufBitWriter<E, WW, WP>
where E: Endianness + 'static + Sync, WW: Sync, WP: Sync,

§

impl<E, WW, WP> Unpin for BufBitWriter<E, WW, WP>
where E: Endianness + 'static + Unpin, WW: Unpin, <WW as WordWrite>::Word: Unpin, WP: Unpin,

§

impl<E, WW, WP> UnwindSafe for BufBitWriter<E, WW, WP>
where E: Endianness + 'static + UnwindSafe, WW: UnwindSafe, <WW as WordWrite>::Word: UnwindSafe, WP: 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<E, B> ExpGolombWrite<E> for B
where E: Endianness, B: BitWrite<E> + GammaWrite<E>,

source§

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

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<T> MemDbg for T
where T: MemDbgImpl,

source§

fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>

Write to stdout debug infos about the structure memory usage, expanding all levels of nested structures.
source§

fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags ) -> Result<(), Error>

Write to a core::fmt::Write debug infos about the structure memory usage, expanding all levels of nested structures.
source§

fn mem_dbg_depth( &self, total_size: usize, max_depth: usize, flags: DbgFlags ) -> Result<(), Error>

Write to stdout debug infos about the structure memory usage, but expanding only up to max_depth levels of nested structures.
source§

fn mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, flags: DbgFlags ) -> Result<(), Error>

Write to a core::fmt::Write debug infos about the structure memory usage, but expanding only up to max_depth levels of nested structures.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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>