Trait didkit::DIDResolver
pub trait DIDResolver: Sync {
// Required method
fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
did: &'life1 str,
input_metadata: &'life2 ResolutionInputMetadata
) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
// Provided methods
fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
did: &'life1 str,
input_metadata: &'life2 ResolutionInputMetadata
) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8, Global>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn dereference<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_primary_did_url: &'life1 PrimaryDIDURL,
_did_url_dereferencing_input_metadata: &'life2 DereferencingInputMetadata
) -> Pin<Box<dyn Future<Output = Option<(DereferencingMetadata, Content, ContentMetadata)>> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn to_did_method(&self) -> Option<&dyn DIDMethod> { ... }
}
Expand description
A DID resolver, implementing the DID Resolution algorithm and optionally DID URL Dereferencing.
Example
An example of a DID resolver with a static DID document.
use async_trait::async_trait;
use ssi_dids::Document;
use ssi_dids::did_resolve::{
DIDResolver, DocumentMetadata, ResolutionInputMetadata, ResolutionMetadata,
ERROR_NOT_FOUND
};
pub struct DIDExampleStatic;
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl DIDResolver for DIDExampleStatic {
async fn resolve(
&self,
did: &str,
_input_metadata: &ResolutionInputMetadata,
) -> (
ResolutionMetadata,
Option<Document>,
Option<DocumentMetadata>,
) {
match did {
"did:example:foo" => {
let doc = match Document::from_json(include_str!("../../tests/did-example-foo.json")) {
Ok(doc) => doc,
Err(e) => {
return (
ResolutionMetadata::from_error(&format!(
"Unable to parse DID document: {:?}",
e
)),
None,
None,
);
}
};
(
ResolutionMetadata::default(),
Some(doc),
Some(DocumentMetadata::default()),
)
}
_ => return (ResolutionMetadata::from_error(ERROR_NOT_FOUND), None, None),
}
}
}
Required Methods§
fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
did: &'life1 str,
input_metadata: &'life2 ResolutionInputMetadata
) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,
i.e. the resolve
function from DID
Core and DID
Resolution.
Provided Methods§
fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
did: &'life1 str,
input_metadata: &'life2 ResolutionInputMetadata
) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8, Global>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8, Global>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,
Resolve a DID in a given representation
i.e. the resolveRepresentation
function from DID
Core and DID
Resolution.
fn dereference<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_primary_did_url: &'life1 PrimaryDIDURL,
_did_url_dereferencing_input_metadata: &'life2 DereferencingInputMetadata
) -> Pin<Box<dyn Future<Output = Option<(DereferencingMetadata, Content, ContentMetadata)>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn dereference<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _primary_did_url: &'life1 PrimaryDIDURL, _did_url_dereferencing_input_metadata: &'life2 DereferencingInputMetadata ) -> Pin<Box<dyn Future<Output = Option<(DereferencingMetadata, Content, ContentMetadata)>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,
Dereference a DID URL.
DID methods implement this function to support
dereferencing DID URLs with
paths and query strings. Callers should use dereference
instead of this function.
fn to_did_method(&self) -> Option<&dyn DIDMethod>
fn to_did_method(&self) -> Option<&dyn DIDMethod>
Cast the resolver as a DIDMethod
, if possible.
Implementations on Foreign Types§
source§impl DIDResolver for DIDEthr
impl DIDResolver for DIDEthr
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, _input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDEthr: 'async_trait,
fn to_did_method(&self) -> Option<&dyn DIDMethod>
source§impl DIDResolver for DIDKey
impl DIDResolver for DIDKey
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, _input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDKey: 'async_trait,
source§impl DIDResolver for DIDOnion
impl DIDResolver for DIDOnion
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDOnion: 'async_trait,
fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8, Global>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDOnion: 'async_trait,
source§impl DIDResolver for DIDPKH
impl DIDResolver for DIDPKH
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, _input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDPKH: 'async_trait,
fn to_did_method(&self) -> Option<&dyn DIDMethod>
source§impl<S> DIDResolver for HTTPSidetreeDIDResolver<S>where
S: Sidetree + Send + Sync,
impl<S> DIDResolver for HTTPSidetreeDIDResolver<S>where S: Sidetree + Send + Sync,
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, HTTPSidetreeDIDResolver<S>: 'async_trait,
source§impl DIDResolver for DIDJWK
impl DIDResolver for DIDJWK
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, _input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDJWK: 'async_trait,
source§impl DIDResolver for DIDTz
impl DIDResolver for DIDTz
source§fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
did: &'life1 str,
input_metadata: &'life2 ResolutionInputMetadata
) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DIDTz: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DIDTz: 'async_trait,
Resolve a did:tz DID.
Resolution options
tzkt_url
Custom indexer endpoint URL.
updates
Off-Chain DID Document Updates, as specified in the Tezos DID Method Specification.
public_key
Public key in Base58 format (publicKeyBase58) to add to a derived DID document (implicit resolution).