Trait compu::encoder::Encoder[][src]

pub trait Encoder: Sized {
    type Options: Default;

    const HAS_INTERNAL_BUFFER: bool;

    fn new(opts: &Self::Options) -> Self;
fn encode(
        &mut self,
        input: &[u8],
        output: &mut [u8],
        op: EncoderOp
    ) -> (usize, usize, bool);
fn output<'a>(&'a mut self) -> Option<&'a [u8]>;
fn compress_size_hint(&self, size: usize) -> usize;
fn is_finished(&self) -> bool; fn default() -> Self { ... } }

Describes compression interface

Associated Types

type Options: Default[src]

Encoder options

Loading content...

Associated Constants

const HAS_INTERNAL_BUFFER: bool[src]

Specifies whether encoder has own internal buffer.

Loading content...

Required methods

fn new(opts: &Self::Options) -> Self[src]

Creates new instance using provided options.

fn encode(
    &mut self,
    input: &[u8],
    output: &mut [u8],
    op: EncoderOp
) -> (usize, usize, bool)
[src]

Performs encoding of data chunk.

Returns tuple that contains: remaining input to process, remaining output buffer size and whether encode is successful.

Use op equal to EncoderOp::Finish to specify last chunk

fn output<'a>(&'a mut self) -> Option<&'a [u8]>[src]

Retrieves currently buffered output, that hasn’t been written yet.

Returned bytes MUST be marked as consumed by implementation.

fn compress_size_hint(&self, size: usize) -> usize[src]

Returns estimated number of bytes, for compressed input.

Note that it might not be reliable, depending on encoder.

fn is_finished(&self) -> bool[src]

Returns whether encoder has finished.

Loading content...

Provided methods

fn default() -> Self[src]

Creates new instance using default Options

Loading content...

Implementors

impl Encoder for BrotliEncoder[src]

type Options = BrotliOptions

impl Encoder for ZlibEncoder[src]

type Options = ZlibOptions

Loading content...