Skip to main content

SampleCodec

Trait SampleCodec 

Source
pub trait SampleCodec: Sync {
    // Required methods
    fn id(&self) -> u8;
    fn encode(&self, buffer: &Buffer, out: &mut Vec<u8>);
    fn decode(
        &self,
        bytes: &[u8],
        rate: u32,
        width: usize,
        samples: usize,
    ) -> Option<Buffer>;
}
Expand description

A persisted entry’s samples. The id is written into every entry, and a store reading an entry another codec wrote answers a miss: the bytes are not wrong, only not its own.

Only an exact codec, one whose round trip is bit-identical, may implement this until keyed, opt-in approximate storage exists: a lossy one would change the value a key names.

Required Methods§

Source

fn id(&self) -> u8

Source

fn encode(&self, buffer: &Buffer, out: &mut Vec<u8>)

Source

fn decode( &self, bytes: &[u8], rate: u32, width: usize, samples: usize, ) -> Option<Buffer>

None unless bytes is exactly width planes of samples each.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§