pub struct ResolverBuilder { /* private fields */ }Expand description
Builds a Resolver.
§Examples
use std::time::Duration;
use identity_kit::did::{
Did, ResolutionError, ResolutionErrorKind, ResolutionOptions, ResolutionResult,
};
use identity_kit::resolver::{DidResolver, Resolver};
struct Nothing;
#[async_trait::async_trait]
impl DidResolver for Nothing {
fn method(&self) -> &'static str {
"example"
}
async fn resolve(
&self,
_: &Did,
_: &ResolutionOptions,
) -> Result<ResolutionResult, ResolutionError> {
Err(ResolutionErrorKind::NotFound.into())
}
}
let resolver = Resolver::builder()
.with(Nothing)
.cache(Duration::from_secs(60))
.build();
assert_eq!(resolver.methods(), ["example"]);
assert!(resolver.supports("example") && !resolver.supports("web"));
assert_eq!(resolver.cache().map(|cache| cache.ttl()), Some(Duration::from_secs(60)));Implementations§
Source§impl ResolverBuilder
impl ResolverBuilder
Sourcepub fn with(self, resolver: impl DidResolver + 'static) -> Self
pub fn with(self, resolver: impl DidResolver + 'static) -> Self
Registers resolver for its method, replacing any resolver registered for the same
method before, so a later registration overrides a default.
Sourcepub fn with_arc(self, resolver: Arc<dyn DidResolver>) -> Self
pub fn with_arc(self, resolver: Arc<dyn DidResolver>) -> Self
Registers an already shared resolver, as with.
Sourcepub fn cache(self, ttl: Duration) -> Self
pub fn cache(self, ttl: Duration) -> Self
Caches resolution results for ttl in a DocumentCache of default capacity.
Sourcepub fn with_cache(self, cache: DocumentCache) -> Self
pub fn with_cache(self, cache: DocumentCache) -> Self
Caches resolution results in cache.
Trait Implementations§
Source§impl Debug for ResolverBuilder
impl Debug for ResolverBuilder
Auto Trait Implementations§
impl !Freeze for ResolverBuilder
impl !RefUnwindSafe for ResolverBuilder
impl !UnwindSafe for ResolverBuilder
impl Send for ResolverBuilder
impl Sync for ResolverBuilder
impl Unpin for ResolverBuilder
impl UnsafeUnpin for ResolverBuilder
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