pub struct Resolver { /* private fields */ }Expand description
Routes each DID to the DidResolver registered for its method, with an optional
DocumentCache in front.
Built with Resolver::builder. The resolver is Send + Sync and meant to be shared, in an
Arc or by reference, by every task of an application. See the module
documentation for the resolution and dereferencing semantics and an example.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub async fn dereference(
&self,
url: &DidUrl,
) -> Result<Dereferenced, DereferenceError>
pub async fn dereference( &self, url: &DidUrl, ) -> Result<Dereferenced, DereferenceError>
Dereferences url: the DID document when the URL is a bare DID, else the verification
method or service whose id is the URL. The fragment is looked up against the id of the
resolved document, which is the canonical DID when url names an equivalent one.
The versionId and versionTime DID parameters select the version of the document and
are passed to the method’s resolver as resolution options. A path, any other query
parameter and the service/relativeRef parameters are method-specific and not
dereferenced here.
§Errors
DereferenceError::Resolutionwhen resolving the DID fails.DereferenceError::InvalidDidUrlwhen a DID parameter is given twice.DereferenceError::MethodSpecificfor a path or a query this crate does not handle.DereferenceError::Deactivatedwhen the DID has been deactivated.DereferenceError::NotFoundwhen nothing in the document has the id of the URL.
Sourcepub async fn resolve_verification_method(
&self,
url: &DidUrl,
relationship: Option<VerificationRelationship>,
) -> Result<VerificationMethod, DereferenceError>
pub async fn resolve_verification_method( &self, url: &DidUrl, relationship: Option<VerificationRelationship>, ) -> Result<VerificationMethod, DereferenceError>
The verification method url names, which must be usable for relationship when one
is given (the verificationRelationship dereferencing option of DID Resolution).
§Errors
As dereference, plus DereferenceError::NotVerificationMethod
when the URL has no fragment or names a service, and
DereferenceError::NotInRelationship when the method is not referenced or embedded
under relationship.
Sourcepub async fn resolve_public_key(
&self,
url: &DidUrl,
relationship: Option<VerificationRelationship>,
) -> Result<Jwk, DereferenceError>
pub async fn resolve_public_key( &self, url: &DidUrl, relationship: Option<VerificationRelationship>, ) -> Result<Jwk, DereferenceError>
The public key of the verification method url names, as a JWK: its publicKeyJwk,
or its publicKeyMultibase decoded as a Multikey. The method must be usable for
relationship when one is given: assertionMethod for the key that signed a
credential, authentication for the key that signed a presentation.
§Errors
As resolve_verification_method, plus
DereferenceError::NoJwk when the method carries publicKeyMultibase material that
is not a Multikey this crate can decode.
Source§impl Resolver
impl Resolver
Sourcepub fn builder() -> ResolverBuilder
pub fn builder() -> ResolverBuilder
A builder with no method registered and no cache.
Sourcepub fn supports(&self, method: &str) -> bool
pub fn supports(&self, method: &str) -> bool
Whether a resolver for method (web, not did:web) is registered.
Sourcepub fn resolver(&self, method: &str) -> Option<&Arc<dyn DidResolver>>
pub fn resolver(&self, method: &str) -> Option<&Arc<dyn DidResolver>>
The resolver registered for method, if any.
Sourcepub fn cache(&self) -> Option<&DocumentCache>
pub fn cache(&self) -> Option<&DocumentCache>
The cache, when the resolver was built with one.
Sourcepub async fn resolve(
&self,
did: &Did,
) -> Result<ResolutionResult, ResolutionError>
pub async fn resolve( &self, did: &Did, ) -> Result<ResolutionResult, ResolutionError>
Resolves did without options, through the cache when there is one.
On success the result holds the document, or no document and deactivated: true in its
document metadata when the DID has been deactivated.
§Errors
ResolutionErrorKind::MethodNotSupported when no resolver is registered for the method
of did; otherwise what the method’s resolver reports, as Err or in its resolution
metadata; ResolutionErrorKind::NotFound when it reports neither a document nor an error
nor deactivation; ResolutionErrorKind::InvalidDidDocument when the document’s id is
neither did nor the canonicalId of the document metadata.
Sourcepub async fn resolve_with(
&self,
did: &Did,
options: &ResolutionOptions,
) -> Result<ResolutionResult, ResolutionError>
pub async fn resolve_with( &self, did: &Did, options: &ResolutionOptions, ) -> Result<ResolutionResult, ResolutionError>
Sourcepub async fn resolve_document(
&self,
did: &Did,
) -> Result<DidDocument, ResolutionError>
pub async fn resolve_document( &self, did: &Did, ) -> Result<DidDocument, ResolutionError>
The DID document of did.
§Errors
As resolve; a deactivated DID is ResolutionErrorKind::NotFound, even
when the method still returns its last document.
Trait Implementations§
Source§impl KeyResolver for Resolver
Resolves a KeyReference::DidUrl by dereferencing it to a verification method listed
under the relationship of the role; every other reference is
Unsupported.
impl KeyResolver for Resolver
Resolves a KeyReference::DidUrl by dereferencing it to a verification method listed
under the relationship of the role; every other reference is
Unsupported.