pub trait BitWrite<E: Endianness> {
type Error: Error + Send + Sync + 'static;
// Required methods
fn write_bits(
&mut self,
value: u64,
num_bits: usize,
) -> Result<usize, Self::Error>;
fn write_unary(&mut self, n: 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 specifies basic operations over which codes can be implemented
by traits such as crate::codes::gamma::GammaWriteParam.
Required Associated Types§
Required Methods§
Sourcefn write_bits(
&mut self,
value: u64,
num_bits: usize,
) -> Result<usize, Self::Error>
fn write_bits( &mut self, value: u64, num_bits: usize, ) -> Result<usize, Self::Error>
Writes the lowest num_bits bits of value to the stream and
returns the number of bits written, that is, num_bits.
Implementors should check the value of num_bits 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.
Provided Methods§
Sourcefn copy_from<F: Endianness, R: BitRead<F>>(
&mut self,
bit_read: &mut R,
n: u64,
) -> Result<(), CopyError<R::Error, Self::Error>>
fn copy_from<F: Endianness, R: BitRead<F>>( &mut self, bit_read: &mut R, n: u64, ) -> Result<(), CopyError<R::Error, Self::Error>>
Copy bits from a BitRead stream to self.
Note that when the endianness F of the source is different from the
endianness E of the destination, the resulting bit order is
implementation-dependent, as bits are copied in chunks, and each chunk
is written in the bit order of the destination.
§Errors
This method can return a CopyError if the source stream returns an
error while reading, or if the destination stream returns an error while
writing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".