Skip to main content

Codec

Trait Codec 

Source
pub trait Codec: Sync {
    // Required methods
    fn id(&self) -> &'static str;
    fn encode(
        &self,
        src: &[u8],
        frame: Frame,
        out: &mut dyn Write,
    ) -> Result<u64>;
    fn decode(
        &self,
        data: &[u8],
        frame: Frame,
        out: &mut dyn Write,
    ) -> Result<u64>;
}
Expand description

A lossless image codec operating on raw sample bytes.

Implementations must be exactly reversible. This is asserted end-to-end on every archive rather than trusted.

Required Methods§

Source

fn id(&self) -> &'static str

Short stable identifier recorded in the archive manifest, so a future version knows which backend produced a payload.

Source

fn encode(&self, src: &[u8], frame: Frame, out: &mut dyn Write) -> Result<u64>

Encode src (raw samples in the file’s byte order), writing the compressed representation to out. Returns bytes written.

Source

fn decode(&self, data: &[u8], frame: Frame, out: &mut dyn Write) -> Result<u64>

Decode data, writing raw samples in the file’s byte order to out. Returns bytes written.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§