Skip to main content

Codec

Trait Codec 

Source
pub trait Codec {
    // Required methods
    fn id(&self) -> &'static str;
    fn detect(&self, prefix: &[u8]) -> Confidence;
    fn inspect_impl(
        &self,
        ctx: &DecodeContext<'_>,
        root: View<'_>,
    ) -> Result<ContainerSummary, CodecError>;
    fn decode_impl(
        &self,
        ctx: &DecodeContext<'_>,
        root: View<'_>,
    ) -> Result<DecodeResult, CodecError>;
}
Expand description

Decoder and container inspector for one source format.

Required Methods§

Source

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

Stable short id for this codec, e.g. "f3d".

Source

fn detect(&self, prefix: &[u8]) -> Confidence

Judge, from a leading byte prefix, whether this codec applies.

Source

fn inspect_impl( &self, ctx: &DecodeContext<'_>, root: View<'_>, ) -> Result<ContainerSummary, CodecError>

Enumerate the acquired root view’s streams/segments without decoding geometry.

Implemented by each codec; never called by the CLI or registry. The CodecEntry::inspect wrapper acquires the root under the inspection’s input limit and runs this under an internal context.

Source

fn decode_impl( &self, ctx: &DecodeContext<'_>, root: View<'_>, ) -> Result<DecodeResult, CodecError>

Decode the acquired root view, reporting incomplete or approximate transfer.

Implemented by each codec; never called by the CLI or registry. The CodecEntry::decode wrapper acquires the root and finalizes the context around this call.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§