Skip to main content

Codec

Trait Codec 

Source
pub trait Codec: Send + Sync {
    // Required methods
    fn kind(&self) -> CodecKind;
    fn compress<'life0, 'async_trait>(
        &'life0 self,
        input: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<(Bytes, ChunkManifest), CodecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn decompress<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: Bytes,
        manifest: &'life1 ChunkManifest,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, CodecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

pluggable な圧縮 backend trait。

すべて async — GPU codec は CUDA stream に await でき、CPU codec は spawn_blocking で別スレッドへ逃がす。

Required Methods§

Source

fn kind(&self) -> CodecKind

この実装が提供する codec の種類

Source

fn compress<'life0, 'async_trait>( &'life0 self, input: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(Bytes, ChunkManifest), CodecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

圧縮: 入力 bytes → 圧縮済 bytes + manifest

Source

fn decompress<'life0, 'life1, 'async_trait>( &'life0 self, input: Bytes, manifest: &'life1 ChunkManifest, ) -> Pin<Box<dyn Future<Output = Result<Bytes, CodecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

解凍: 圧縮済 bytes + manifest → 元の bytes

Implementors§