pub struct NodeResolver { /* private fields */ }Expand description
Node DID resolver
This resolver combines multiple DID resolvers for different DID methods, providing a unified interface for resolving DIDs across various methods.
The resolver supports:
- did:key method, which is used for keys represented as DIDs
- Multi-resolver, which combines multiple method-specific resolvers
§Resolution Process
When a DID is received for resolution:
- The method is extracted from the DID (e.g., “key” from “did:key:z6Mk…”)
- The appropriate resolver for that method is selected
- The resolver processes the DID and returns a DID Document
- The DID Document provides cryptographic material and service endpoints
§Thread Safety
The NodeResolver is thread-safe and can be safely shared across threads
using Arc<NodeResolver>. All mutable state is protected by RwLock.
Implementations§
Source§impl NodeResolver
impl NodeResolver
Sourcepub async fn add_resolver(
&self,
method: String,
resolver: Arc<dyn SyncDIDResolver>,
)
pub async fn add_resolver( &self, method: String, resolver: Arc<dyn SyncDIDResolver>, )
Add a resolver for a DID method
Sourcepub async fn get_resolver(&self, did: &str) -> Option<Arc<dyn SyncDIDResolver>>
pub async fn get_resolver(&self, did: &str) -> Option<Arc<dyn SyncDIDResolver>>
Get a resolver for a DID method
Sourcepub async fn resolve(&self, did: &str) -> Result<Value>
pub async fn resolve(&self, did: &str) -> Result<Value>
Resolve a DID to a DID Document
This method takes a DID and returns the corresponding DID Document. The DID Document contains the cryptographic material and service endpoints associated with the DID.
§Parameters
did- The DID to resolve
§Returns
The DID Document as a JSON Value
§Errors
Returns an error if:
- No resolver is found for the DID method
- The DID resolution fails
- The DID Document cannot be serialized to JSON
Trait Implementations§
Source§impl Default for NodeResolver
impl Default for NodeResolver
Source§fn default() -> NodeResolver
fn default() -> NodeResolver
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for NodeResolver
impl !RefUnwindSafe for NodeResolver
impl Send for NodeResolver
impl Sync for NodeResolver
impl Unpin for NodeResolver
impl !UnwindSafe for NodeResolver
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
Mutably borrows from an owned value. Read more