#[non_exhaustive]pub enum ContentError {
EncodingError {
source: Box<dyn Error + Send + Sync + 'static>,
},
DecodingError {
source: Box<dyn Error + Send + Sync + 'static>,
},
VerificationFailed {
expected: String,
computed: String,
},
NonCanonical,
InvalidCid {
reason: String,
source: Box<dyn Error + Send + Sync + 'static>,
},
InvalidCidProfile {
reason: String,
},
}Expand description
The error type returned by all fallible operations in this crate.
Variants are intentionally coarse: they describe which stage failed
(serialize, deserialize, verify, non-canonical, parse) rather than mirroring
every underlying library error one-to-one. Where a lower-level error is
available it is preserved in the source field for diagnostics.
§Stability (FROZEN at 0.1.0)
This enum is #[non_exhaustive] as a frozen decision: it lets a new
variant be added in a future 0.1.x release without a major version bump,
while the four (now five) names and their fields below are a stability
contract. See the module docs for the full freeze rationale (no
#[from], boxed codec sources, the operation→variant map) and a compile-time
Send + Sync + 'static guard locking ContentError’s thread-portability.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EncodingError
Canonical dag-cbor encoding of a value failed.
Returned by
to_canonical_dagcbor (and so
propagated by content_id /
verify via canonical_form). The
source is boxed as a dyn Error so the concrete
serde_ipld_dagcbor::EncodeError<…> generic does not leak into this
frozen signature.
DecodingError
Decoding canonical dag-cbor bytes back into a value failed.
Returned by
from_canonical_dagcbor and
by from_canonical_bytes_checked
when the input bytes are not dag-cbor at all. The source is boxed as a
dyn Error so the concrete serde_ipld_dagcbor::DecodeError<…> generic
does not leak into this frozen signature.
VerificationFailed
A crate::ContentId did not match the expected one.
This is the heart of the doctrine: the data did not carry the proof it claimed to. The recomputed identity differs from the expected identity.
§Frozen verify ruling (0.1.0)
verify returns Ok(false) on a
mismatch — a mismatch is not an Err (a negative answer to “do these
match?” is a successful, expected result, not a failure to check). This
is a frozen part of the 0.1.0 API surface (README gate item #8).
This variant is the escalation of that boolean: it is constructed by
ensure_content_id, the
strict helper that turns a mismatch into an Err for ?-propagation.
Its expected / computed fields are the two ids’ Display strings
(multibase base32-lower b…).
Fields
NonCanonical
Bytes presented as canonical dag-cbor were valid CBOR but not canonical dag-cbor.
Returned only by the opt-in
from_canonical_bytes_checked
when the input decodes as an Ipld value but
re-encoding it does not reproduce the input bytes (wrong map-key
order, indefinite-length items, non-smallest integers, …). The fast
from_canonical_bytes primitive
never produces this — it trusts its precondition and only hashes.
InvalidCid
A CID could not be parsed from a string or from bytes.
Returned by ContentId::from_bytes and
the FromStr impl. reason is a stable
human-readable string; the underlying cid::Error is preserved in
source so the error chain (.source()) is not stripped at this
boundary.
Fields
InvalidCidProfile
A syntactically-valid CID was parsed, but it is not this crate’s frozen
profile: CIDv1 + dag-cbor (0x71) + BLAKE3 (0x1e) + a 32-byte digest.
Every ingress path — from_bytes, the
FromStr impl, TryFrom<Cid>, and
the binary/IPLD Deserialize — rejects a foreign CID with this, so every
ContentId (however it entered) carries the fixed profile the presentation
accessors (digest_bytes etc.) rely on.
A policy rejection, so — like NonCanonical —
it carries no underlying source; reason names the parameter that was off.
Trait Implementations§
Source§impl Debug for ContentError
impl Debug for ContentError
Source§impl Display for ContentError
impl Display for ContentError
Source§impl Error for ContentError
impl Error for ContentError
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()