Struct dsi_bitstream::impls::BufBitWriter
source · 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>,
impl<E: Endianness, WW: WordWrite, WP: WriteParams> BufBitWriter<E, WW, WP>where
BufBitWriter<E, WW, WP>: BitWrite<E>,
sourcepub fn new(backend: WW) -> Self
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);
sourcepub fn into_inner(self) -> Result<WW, <Self as BitWrite<E>>::Error>
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>
impl<WW: WordWrite, WP: WriteParams> BitWrite<BigEndian> for BufBitWriter<BE, WW, WP>
type Error = <WW as WordWrite>::Error
source§fn flush(&mut self) -> Result<usize, Self::Error>
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>
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 moresource§fn write_unary(&mut self, value: u64) -> Result<usize, Self::Error>
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.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>
impl<WW: WordWrite, WP: WriteParams> BitWrite<LittleEndian> for BufBitWriter<LE, WW, WP>
type Error = <WW as WordWrite>::Error
source§fn flush(&mut self) -> Result<usize, Self::Error>
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>
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 moresource§fn write_unary(&mut self, value: u64) -> Result<usize, Self::Error>
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.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>
impl<E: Endianness, WW, WP: WriteParams> CopyType for BufBitWriter<E, WW, WP>
source§impl<E: Debug + Endianness, WW: Debug + WordWrite, WP: Debug + WriteParams> Debug for BufBitWriter<E, WW, WP>
impl<E: Debug + Endianness, WW: Debug + WordWrite, WP: Debug + WriteParams> Debug for BufBitWriter<E, WW, WP>
source§impl<WR: WordWrite, DC: WriteParams> DeltaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
impl<WR: WordWrite, DC: WriteParams> DeltaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
source§impl<WR: WordWrite, DC: WriteParams> DeltaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
impl<WR: WordWrite, DC: WriteParams> DeltaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
source§impl<E: Endianness, WW: WordWrite, WP: WriteParams> Drop for BufBitWriter<E, WW, WP>
impl<E: Endianness, WW: WordWrite, WP: WriteParams> Drop for BufBitWriter<E, WW, WP>
source§impl<WR: WordWrite> GammaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DefaultWriteParams>
impl<WR: WordWrite> GammaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DefaultWriteParams>
source§impl<WR: WordWrite> GammaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DefaultWriteParams>
impl<WR: WordWrite> GammaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DefaultWriteParams>
source§impl<E: Endianness, WW, WP: WriteParams> MemDbgImpl for BufBitWriter<E, WW, WP>where
WW: MemDbgImpl + WordWrite,
WW::Word: MemDbgImpl,
usize: MemDbgImpl,
PhantomData<(E, WP)>: MemDbgImpl,
impl<E: Endianness, WW, WP: WriteParams> MemDbgImpl for BufBitWriter<E, WW, WP>where
WW: MemDbgImpl + WordWrite,
WW::Word: MemDbgImpl,
usize: MemDbgImpl,
PhantomData<(E, WP)>: MemDbgImpl,
source§impl<E: Endianness, WW, WP: WriteParams> MemSize for BufBitWriter<E, WW, WP>
impl<E: Endianness, WW, WP: WriteParams> MemSize for BufBitWriter<E, WW, WP>
source§impl<WR: WordWrite, DC: WriteParams> ZetaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
impl<WR: WordWrite, DC: WriteParams> ZetaWrite<BigEndian> for BufBitWriter<BigEndian, WR, DC>
source§impl<WR: WordWrite, DC: WriteParams> ZetaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
impl<WR: WordWrite, DC: WriteParams> ZetaWrite<LittleEndian> for BufBitWriter<LittleEndian, WR, DC>
Auto Trait Implementations§
impl<E, WW, WP> Freeze for BufBitWriter<E, WW, WP>
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>
impl<E, WW, WP> Sync for BufBitWriter<E, WW, WP>
impl<E, WW, WP> Unpin for BufBitWriter<E, WW, WP>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
source§impl<B> DeltaWriteParam<BigEndian> for Bwhere
B: GammaWriteParam<BigEndian>,
impl<B> DeltaWriteParam<BigEndian> for Bwhere
B: GammaWriteParam<BigEndian>,
source§impl<B> DeltaWriteParam<LittleEndian> for Bwhere
B: GammaWriteParam<LittleEndian>,
impl<B> DeltaWriteParam<LittleEndian> for Bwhere
B: GammaWriteParam<LittleEndian>,
source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
source§impl<E, B> ExpGolombWrite<E> for B
impl<E, B> ExpGolombWrite<E> for B
source§impl<B> GammaWriteParam<BigEndian> for B
impl<B> GammaWriteParam<BigEndian> for B
source§impl<B> GammaWriteParam<LittleEndian> for Bwhere
B: BitWrite<LittleEndian>,
impl<B> GammaWriteParam<LittleEndian> for Bwhere
B: BitWrite<LittleEndian>,
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 Bwhere
E: Endianness,
B: BitWrite<E>,
impl<E, B> GolombWrite<E> for Bwhere
E: Endianness,
B: BitWrite<E>,
source§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
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>
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>
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>
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 Bwhere
E: Endianness,
B: BitWrite<E>,
impl<E, B> MinimalBinaryWrite<E> for Bwhere
E: Endianness,
B: BitWrite<E>,
source§impl<E, B> RiceWrite<E> for Bwhere
E: Endianness,
B: BitWrite<E>,
impl<E, B> RiceWrite<E> for Bwhere
E: Endianness,
B: BitWrite<E>,
source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.