Trait dsi_bitstream::traits::BitWrite
source · pub trait BitWrite<E: Endianness> {
type Error: Error;
// Required methods
fn write_bits(&mut self, value: u64, n: usize) -> Result<usize, Self::Error>;
fn write_unary_param<const USE_TABLE: bool>(
&mut self,
value: u64
) -> Result<usize, Self::Error>;
fn flush(self) -> Result<(), Self::Error>;
// Provided method
fn write_unary(&mut self, value: u64) -> Result<usize, 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§
Required Methods§
sourcefn write_bits(&mut self, value: u64, n: usize) -> Result<usize, Self::Error>
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
when the checks
feature is
enabled and panic if it is greater than 64. Moreover, under the same
conditions they should check that the remaining bits of value
are
zero.
sourcefn write_unary_param<const USE_TABLE: bool>(
&mut self,
value: u64
) -> Result<usize, Self::Error>
fn write_unary_param<const USE_TABLE: bool>( &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.
This version of the method has a constant parameter
deciding whether to use an encoding table. You should rather use
BitWrite::write_unary
, which uses the default
choice of the implementing type.
Provided Methods§
sourcefn 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.
This version of the method uses the version of
of BitWrite::write_unary_param
selected as default by
the implementing type. The default implementation
uses a table.