pub trait Padding {
// Required methods
fn max_size(&self) -> usize;
fn pad<W: Write>(
&self,
last_byte: u8,
byte_fill: u8,
writer: &mut W,
) -> IOResult<()>;
fn bits_left(&self, last_bytes: &[u8]) -> IOResult<usize>;
}
Expand description
Required Methods§
Sourcefn max_size(&self) -> usize
fn max_size(&self) -> usize
Get the maximum size of the padding.
This is used to determine how many bytes should be passed to bits_left
Sourcefn pad<W: Write>(
&self,
last_byte: u8,
byte_fill: u8,
writer: &mut W,
) -> IOResult<()>
fn pad<W: Write>( &self, last_byte: u8, byte_fill: u8, writer: &mut W, ) -> IOResult<()>
Pad the last bits of the stream.
This is called by BitWriter on drop to make sure the last bits are written to the output, using the specified padding. The padding is responsible for writing the last byte, or else it may lead to unintended loss of data.
Sourcefn bits_left(&self, last_bytes: &[u8]) -> IOResult<usize>
fn bits_left(&self, last_bytes: &[u8]) -> IOResult<usize>
Determine how many bits are left to read.
This is called by BitReader when encountering the last byte in the
input stream. This will be called with the last n
bytes of the input stream, where n
is max_size()
, or fewer, if there are fewer bytes in the whole input
stream.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.