pub struct DerError { /* private fields */ }Expand description
Opaque wrapper around an underlying ASN.1 / DER error.
Carries a Display message identical to the wrapped der::Error so
diagnostic output is preserved, but does not expose the underlying type
in the public API. This insulates callers from semver-breaking changes
in the der crate’s error variants.
Construct via DerError::new (or implicitly via
[From<der::Error> for Error]). Sibling workspace crates that wrap
DER decoding failures in their own Error enums (pkix-revocation,
pkix-truststore) call DerError::new directly.
§Serde wire form
When the serde feature is enabled, DerError (de)serializes via its
Display message as a single String field. Because der::Error does
not itself carry a textual message — its Display is derived from
der::ErrorKind — round-trip is lossy: a deserialized DerError
preserves the original Display output verbatim but its
core::error::Error::source is None because the original
der::Error value cannot be reconstructed from a free-form string.
This trade is acceptable for diagnostic error types; the success type
(ValidatedPath) round-trips losslessly because all its fields are
canonically DER-encodable.
Implementations§
Source§impl DerError
impl DerError
Sourcepub fn new(e: Error) -> Self
pub fn new(e: Error) -> Self
Construct a DerError from a real der::Error.
The original der::Error is preserved internally so
core::error::Error::source returns it; the rendered
Display message is cached so the diagnostic survives serde
round-trips. See the type-level rustdoc for the round-trip
fidelity contract.
Exposed to permit sibling workspace crates (pkix-revocation,
pkix-truststore) to construct their own Error::Der-equivalent
variants from der::Error results without going through the
pkix_path::Error::from(der::Error) conversion (which would
produce a pkix_path::Error, not the sibling crate’s Error).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DerError
Available on crate feature serde only.
impl<'de> Deserialize<'de> for DerError
serde only.Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl Eq for DerError
Source§impl Error for DerError
impl Error for DerError
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 Hash for DerError
Hashes message, the one field PartialEq compares.
impl Hash for DerError
Hashes message, the one field PartialEq compares.
That correspondence is the whole argument for correctness: Hash
requires that equal values hash equally, and since equality here is
defined solely by message, hashing solely message cannot violate
it. Hashing inner as well would break the contract, because
inner is dropped on a serde round-trip while equality is preserved
— two equal values would then hash differently.
Written out rather than derived for that reason: a derive would
include inner.
This exists so Error can derive Hash. Der(DerError) was the
only variant standing in the way, which in turn is why
pkix_path_builder::Error::NoValidPath stores its inner error as a
rendered String — the builder’s own enum derives Hash and could
not hold a non-Hash field. That storage choice is now a semver
question rather than a technical obstacle.