#[non_exhaustive]pub enum CodecError {
WrongFormat(String),
Malformed(String),
InvalidInput(String),
Truncated {
location: SourceLocation,
operation: &'static str,
},
ResourceLimit(ResourceLimit),
UnsupportedDialect {
dialects: Box<DialectLayers>,
message: String,
},
UnsupportedTarget(Box<TargetRefusal>),
InsufficientDepth {
format: &'static str,
needed: DecodeDepth,
recorded: DecodeDepth,
},
NotImplemented(String),
Io(Error),
}Expand description
Errors a codec can raise.
Marked #[non_exhaustive]: external exhaustive matches must carry a
wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
WrongFormat(String)
The bytes are not this codec’s format.
Malformed(String)
The container was structurally malformed.
InvalidInput(String)
The document supplied to an encoder violates its input contract.
Truncated
A required read extended past the end of its window after commitment.
Distinct from CodecError::Malformed: a truncation is missing input,
not an inconsistency inside the bytes that are present.
Fields
location: SourceLocationWhere the truncated read began.
ResourceLimit(ResourceLimit)
A resource limit refused the decode: policy or the allocator.
Never reported as CodecError::Malformed: a budget refusal is a
statement about policy, not about the input.
UnsupportedDialect
The document was identified, and its dialect is not supported.
Never reported as CodecError::WrongFormat: the bytes are this
codec’s format, and the codec says so by carrying the identification it
made. Identity survives refusal, so a caller can name what it was handed
even though nothing was decoded.
The SAT codec constructs this variant for a recognized stream kind that does not frame. The STEP codec constructs it for the Part 26 HDF5, Part 28 XML, and AP242 business-object XML encodings that it identifies but does not decode.
The identification is boxed: it is the widest payload any variant of
this enum carries, and every Result<_, CodecError> in the workspace
would otherwise grow to its width.
Fields
dialects: Box<DialectLayers>Every format layer identified before the refusal.
UnsupportedTarget(Box<TargetRefusal>)
The encoder could not resolve or deliver a write target.
InsufficientDepth
The document records less of its source than the encoder plans from.
Fields
needed: DecodeDepthThe least depth the encoder plans from.
recorded: DecodeDepthThe depth the document records.
NotImplemented(String)
The codec does not implement a required capability.
Io(Error)
Underlying I/O failure.
Implementations§
Source§impl CodecError
impl CodecError
Trait Implementations§
Source§impl Debug for CodecError
impl Debug for CodecError
Source§impl Display for CodecError
impl Display for CodecError
Source§impl Error for CodecError
impl Error for CodecError
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()
Source§impl From<DialectLayerError> for CodecError
impl From<DialectLayerError> for CodecError
Source§fn from(error: DialectLayerError) -> Self
fn from(error: DialectLayerError) -> Self
Source§impl From<Error> for CodecError
impl From<Error> for CodecError
Source§impl From<NamedEntryError> for CodecError
A source property whose key names nothing, or whose key the record already
states, is an inconsistency inside the bytes that are present, so a reader
that refuses the whole property set reports it as a malformed container.
impl From<NamedEntryError> for CodecError
A source property whose key names nothing, or whose key the record already states, is an inconsistency inside the bytes that are present, so a reader that refuses the whole property set reports it as a malformed container.