#[non_exhaustive]pub enum DecodeError {
UnsupportedContainer {
tag: FourCc,
},
UnsupportedCodec {
codec: CodecId,
},
UnsupportedSampleFormat {
format: CodecId,
bits_per_sample: u16,
},
UnsupportedChannelLayout {
channels: u16,
},
Malformed {
expected: &'static str,
offset: u64,
},
Truncated {
expected: u64,
available: u64,
},
ContainerCodecMismatch {
declared: CodecId,
found: CodecId,
},
Resample(ResamplerError),
}Expand description
Every way decoding can fail.
The variant list is closed by design rather than grown as codecs land. Each
variant decibri surfaces has to be registered by name, code and sample
instance in the error_identity! table in decibri’s error.rs, and that
macro has no catch-all arm, so a variant added later is a change in two
crates and a new stable code on decibri’s frozen error surface. Settling the
list while the crate is empty costs nothing; growing it later costs a
version bump in both crates.
The four Unsupported* variants are split rather than folded into one for
the reason recorded on CodecId: “unsupported” alone does not tell a
caller which encoding they hit or what to do about it.
This enum is #[non_exhaustive]: consumers pattern-matching on it must
include a _ => catch-all arm so future variant additions are not
source-breaking.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedContainer
The container format was not recognised.
Carries the identifying bytes that were seen at the start of the input, so a caller can tell “this is not audio at all” from “this is audio in a container this build does not carry”.
UnsupportedCodec
The container parsed and named a codec this build does not support.
Distinct from UnsupportedContainer: the
file is well-formed and its structure was understood. Only the payload
encoding is out of reach.
UnsupportedSampleFormat
A recognised codec in a sample format this build does not support.
Distinct from UnsupportedCodec: the codec
itself is carried, but not at this width or in this representation,
24-bit PCM where only 16- and 32-bit are implemented, for instance.
Fields
UnsupportedChannelLayout
The channel count or layout is not one this build can decode.
Malformed
A parse failure: the bytes at a known position were not what the format requires there.
Distinct from Truncated, which is about running out
of input rather than finding the wrong input.
Fields
Truncated
The input ended part-way through a frame, a header or a declared length.
From a file this means the file is short. From a stream it means the stream was finished while a frame was still incomplete: a stream that simply has not received the rest yet is not an error, and the stream adapter holds the partial frame instead of reporting one.
Fields
ContainerCodecMismatch
The container declares one codec and the payload is another.
Reached when both identities parse and disagree, a WAVE header claiming
integer PCM over a payload whose frames are mu-law, say. Reported
separately from the Unsupported* variants because nothing here is
unsupported: the file is internally inconsistent and no single decoder
choice is correct.
Fields
Resample(ResamplerError)
Rate conversion failed.
The only variant that chains a source. This crate contains no resampling
logic; it calls decibri-resampler and passes its failure through
unaltered.
Trait Implementations§
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()