#[non_exhaustive]pub enum CodecError {
WrongFormat(String),
Malformed(String),
InvalidInput(String),
Truncated {
location: SourceLocation,
context: ErrorContext,
},
ResourceLimit(ResourceLimit),
StrictRefusal {
loss_code: String,
message: String,
},
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.
context: ErrorContextStatic context for the failure.
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.
StrictRefusal
Strict decode mode refused a reported loss.
Never reported as CodecError::Malformed: a strict refusal is a
statement about the decode mode, not about the input. The bytes can be
well formed and still refuse under strict mode. The strict-mode gate in
the Codec decode wrapper is the only construction site.
Fields
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()