Trait zstd::stream::raw::Operation

pub trait Operation {
    // Required method
    fn run<C>(
        &mut self,
        input: &mut InBuffer<'_>,
        output: &mut OutBuffer<'_, C>,
    ) -> Result<usize, Error>
       where C: WriteBuf + ?Sized;

    // Provided methods
    fn run_on_buffers(
        &mut self,
        input: &[u8],
        output: &mut [u8],
    ) -> Result<Status, Error> { ... }
    fn flush<C>(
        &mut self,
        output: &mut OutBuffer<'_, C>,
    ) -> Result<usize, Error>
       where C: WriteBuf + ?Sized { ... }
    fn reinit(&mut self) -> Result<(), Error> { ... }
    fn finish<C>(
        &mut self,
        output: &mut OutBuffer<'_, C>,
        finished_frame: bool,
    ) -> Result<usize, Error>
       where C: WriteBuf + ?Sized { ... }
}
Expand description

Represents an abstract compression/decompression operation.

This trait covers both Encoder and Decoder.

Required Methods§

fn run<C>( &mut self, input: &mut InBuffer<'_>, output: &mut OutBuffer<'_, C>, ) -> Result<usize, Error>
where C: WriteBuf + ?Sized,

Performs a single step of this operation.

Should return a hint for the next input size.

If the result is Ok(0), it may indicate that a frame was just finished.

Provided Methods§

fn run_on_buffers( &mut self, input: &[u8], output: &mut [u8], ) -> Result<Status, Error>

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.

fn flush<C>(&mut self, output: &mut OutBuffer<'_, C>) -> Result<usize, Error>
where C: WriteBuf + ?Sized,

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).

fn reinit(&mut self) -> Result<(), Error>

Prepares the operation for a new frame.

This is hopefully cheaper than creating a new operation.

fn finish<C>( &mut self, output: &mut OutBuffer<'_, C>, finished_frame: bool, ) -> Result<usize, Error>
where C: WriteBuf + ?Sized,

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.

Object Safety§

This trait is not object safe.

Implementors§

§

impl Operation for Decoder<'_>

§

impl Operation for NoOp

§

impl<'a> Operation for Encoder<'a>