Skip to main content

SourceCoder

Trait SourceCoder 

Source
pub trait SourceCoder {
    // Required methods
    fn try_compress(input: &[u8]) -> Result<Vec<u8>, ErrorsJSL>;
    fn try_decompress(input: &[u8]) -> Result<Vec<u8>, ErrorsJSL>;
}
Expand description

Common interface for byte-oriented source coders in this crate.

A source coder consumes raw bytes and either:

The methods are fallible so callers can handle malformed compressed data or future codec-specific compression failures through the same Result type.

Required Methods§

Source

fn try_compress(input: &[u8]) -> Result<Vec<u8>, ErrorsJSL>

Compress a raw byte slice into a codec-specific byte stream.

The trait keeps the signature intentionally small so generic code can swap one source coder for another without having to learn codec-specific setup APIs first.

Source

fn try_decompress(input: &[u8]) -> Result<Vec<u8>, ErrorsJSL>

Decompress a codec-specific byte stream back into its original bytes.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§