pub struct ResolutionError { /* private fields */ }Expand description
Why a DID could not be resolved: a ResolutionErrorKind keyword, and optionally a
human-readable detail and the underlying error.
The keyword is the error as DID Core defines it: it is what the error serializes as, what
ResolutionMetadata::error reports, and the only part two errors are compared on. The
detail (the HTTP status of a failed did:web fetch, the ids of a mismatched document) and
the source (the HTTP client’s error, the JSON or decoding error)
are diagnostics: they appear in Display and Error::source, and are
lost when the error is serialized.
§Examples
use std::error::Error as _;
use identity_kit::did::{ResolutionError, ResolutionErrorKind};
let cause = std::io::Error::other("connection refused");
let error = ResolutionError::new(ResolutionErrorKind::InternalError)
.with_detail("fetching `https://example.com/.well-known/did.json` failed")
.with_source(cause);
assert_eq!(error.kind(), &ResolutionErrorKind::InternalError);
assert_eq!(error, ResolutionErrorKind::InternalError);
assert_eq!(error.as_str(), "internalError");
assert_eq!(
error.to_string(),
"internal resolver error: fetching `https://example.com/.well-known/did.json` failed: \
connection refused"
);
assert!(error.source().unwrap().downcast_ref::<std::io::Error>().is_some());
assert_eq!(serde_json::to_string(&error)?, r#""internalError""#);Implementations§
Source§impl ResolutionError
impl ResolutionError
Sourcepub const fn new(kind: ResolutionErrorKind) -> Self
pub const fn new(kind: ResolutionErrorKind) -> Self
An error reporting kind, without detail or source.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
This error with a human-readable detail, replacing any previous one.
Sourcepub fn with_source<E: Error + Send + Sync + 'static>(self, source: E) -> Self
pub fn with_source<E: Error + Send + Sync + 'static>(self, source: E) -> Self
This error caused by source, replacing any previous source.
Sourcepub const fn kind(&self) -> &ResolutionErrorKind
pub const fn kind(&self) -> &ResolutionErrorKind
The keyword.
Trait Implementations§
Source§impl Clone for ResolutionError
impl Clone for ResolutionError
Source§impl Debug for ResolutionError
impl Debug for ResolutionError
Source§impl<'de> Deserialize<'de> for ResolutionError
impl<'de> Deserialize<'de> for ResolutionError
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for ResolutionError
impl Display for ResolutionError
impl Eq for ResolutionError
Source§impl Error for ResolutionError
impl Error for ResolutionError
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<DidError> for ResolutionError
impl From<DidError> for ResolutionError
Source§fn from(error: DidError) -> Self
fn from(error: DidError) -> Self
ResolutionErrorKind::InvalidDid, caused by error.
Source§impl From<ResolutionError> for DomainLinkageError
Available on crate feature domain-linkage only.
impl From<ResolutionError> for DomainLinkageError
domain-linkage only.Source§fn from(source: ResolutionError) -> Self
fn from(source: ResolutionError) -> Self
Source§impl From<ResolutionError> for LinkedVpError
Available on crate feature linked-vp only.
impl From<ResolutionError> for LinkedVpError
linked-vp only.Source§fn from(source: ResolutionError) -> Self
fn from(source: ResolutionError) -> Self
Source§impl From<ResolutionErrorKind> for ResolutionError
impl From<ResolutionErrorKind> for ResolutionError
Source§fn from(kind: ResolutionErrorKind) -> Self
fn from(kind: ResolutionErrorKind) -> Self
Source§impl FromStr for ResolutionError
impl FromStr for ResolutionError
Source§impl Hash for ResolutionError
impl Hash for ResolutionError
Source§impl PartialEq for ResolutionError
Errors are equal when their keywords are; the detail and the source are not compared, so an
error equals its own serialization round trip.
impl PartialEq for ResolutionError
Errors are equal when their keywords are; the detail and the source are not compared, so an error equals its own serialization round trip.
Auto Trait Implementations§
impl !RefUnwindSafe for ResolutionError
impl !UnwindSafe for ResolutionError
impl Freeze for ResolutionError
impl Send for ResolutionError
impl Sync for ResolutionError
impl Unpin for ResolutionError
impl UnsafeUnpin for ResolutionError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.