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§
Sourcefn detect(&self, prefix: &[u8]) -> Confidence
fn detect(&self, prefix: &[u8]) -> Confidence
Judge, from a leading byte prefix, whether this codec applies.
Sourcefn inspect_impl(
&self,
ctx: &DecodeContext<'_>,
root: View<'_>,
) -> Result<ContainerSummary, CodecError>
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.
Sourcefn decode_impl(
&self,
ctx: &DecodeContext<'_>,
root: View<'_>,
) -> Result<DecodeResult, CodecError>
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".