Skip to main content

PerCodecTunables

Trait PerCodecTunables 

Source
pub trait PerCodecTunables: Codec {
    type Tunables: Clone + Send + Sync + 'static;

    // Required method
    fn compress_with_owned_tunables(
        &self,
        plaintext: &[u8],
        tunables: &Self::Tunables,
    ) -> Result<Vec<u8>, CoreError>;
}
Expand description

Optional trait: codecs with strongly-typed per-codec tunables.

The flat CodecTunables struct works for today’s six codec families but doesn’t scale. Codecs that want clean OCP for their own knobs implement this trait alongside Codec; new codecs = one impl PerCodecTunables with a fresh Tunables type, no edits to existing code or to the flat struct.

The flat CodecTunables remains the dispatch entry point for callers that want a single uniform struct; codecs that implement PerCodecTunables can read from it inside their compress_with_tunables override.

Required Associated Types§

Source

type Tunables: Clone + Send + Sync + 'static

Per-codec tunables type. Should be Clone + Send + Sync + 'static so it can live in a Box<dyn Any> registry if/when we move to per-codec-keyed tunables dispatch.

Required Methods§

Source

fn compress_with_owned_tunables( &self, plaintext: &[u8], tunables: &Self::Tunables, ) -> Result<Vec<u8>, CoreError>

Compress with this codec’s strongly-typed tunables.

§Errors

Same as Codec::compress.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§