pub trait Operation {
fn run<C: WriteBuf + ?Sized>(
&mut self,
input: &mut InBuffer<'_>,
output: &mut OutBuffer<'_, C>
) -> Result<usize>;
fn run_on_buffers(
&mut self,
input: &[u8],
output: &mut [u8]
) -> Result<Status> { ... }
fn flush<C: WriteBuf + ?Sized>(
&mut self,
output: &mut OutBuffer<'_, C>
) -> Result<usize> { ... }
fn reinit(&mut self) -> Result<()> { ... }
fn finish<C: WriteBuf + ?Sized>(
&mut self,
output: &mut OutBuffer<'_, C>,
finished_frame: bool
) -> Result<usize> { ... }
}
Expand description
Represents an abstract compression/decompression operation.
This trait covers both Encoder
and Decoder
.
Required methods
Provided methods
Performs a single step of this operation.
This is a comvenience wrapper around Operation::run
if you don’t
want to deal with InBuffer
/OutBuffer
.
Flushes any internal buffer, if any.
Returns the number of bytes still in the buffer.
To flush entirely, keep calling until it returns Ok(0)
.
Prepares the operation for a new frame.
This is hopefully cheaper than creating a new operation.
Finishes the operation, writing any footer if necessary.
Returns the number of bytes still to write.
Keep calling this method until it returns Ok(0)
,
and then don’t ever call this method.