pub struct LinkResolver { /* private fields */ }Expand description
In-memory resolver and mirror registry.
Implementations§
Source§impl LinkResolver
impl LinkResolver
Sourcepub fn with_provider_fetch(fetch: ProviderFetch) -> Self
pub fn with_provider_fetch(fetch: ProviderFetch) -> Self
Create a resolver with a provider fetch hook for network resolution.
The fetch function is called when a name link cannot be resolved locally, allowing the caller to query remote peers via iroh-docs.
Sourcepub async fn resolve_remote(
&self,
link: &Link,
) -> Result<Option<LinkResolution>>
pub async fn resolve_remote( &self, link: &Link, ) -> Result<Option<LinkResolution>>
Attempt to resolve a name link by querying remote peers.
Returns None if no provider fetch hook is registered or the link
is not a name link. The caller is responsible for falling back to
local resolution.
§Errors
Returns an error if the remote fetch fails.
Sourcepub fn with_database(database: IndexingDatabase) -> Result<Self>
pub fn with_database(database: IndexingDatabase) -> Result<Self>
Create a resolver backed by an indexing database.
Pointers and mirrors are hydrated from the database on construction. Mutations are persisted through the database.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn register_mirror(&self, ticket: BlobTicket) -> Result<()>
pub fn register_mirror(&self, ticket: BlobTicket) -> Result<()>
Sourcepub fn mirrors(&self, hash: Hash) -> Result<Vec<BlobTicket>>
pub fn mirrors(&self, hash: Hash) -> Result<Vec<BlobTicket>>
Return registered direct mirror tickets in registration order.
§Errors
Returns an error if the resolver state lock is poisoned.
Sourcepub fn publish(&self, pointer: &MutablePointer) -> Result<()>
pub fn publish(&self, pointer: &MutablePointer) -> Result<()>
Accept a signed mutable pointer, enforcing monotonic sequence.
§Errors
Returns an error if the pointer is unsigned, invalid, or older than the current pointer.
Sourcepub fn current_pointer(&self, link: &NameLink) -> Result<Option<MutablePointer>>
pub fn current_pointer(&self, link: &NameLink) -> Result<Option<MutablePointer>>
Return the current pointer for a mutable name.
§Errors
Returns an error if the link is invalid or the resolver state lock is poisoned.
Sourcepub fn revoke(&self, link: &PrivateLink) -> Result<()>
pub fn revoke(&self, link: &PrivateLink) -> Result<()>
Revoke a private capability.
§Errors
Returns an error if the link is invalid or the resolver state lock is poisoned.
Sourcepub fn is_revoked(&self, link: &PrivateLink) -> Result<bool>
pub fn is_revoked(&self, link: &PrivateLink) -> Result<bool>
Return whether a private capability has been revoked.
§Errors
Returns an error if the link is invalid or the resolver state lock is poisoned.
Sourcepub fn resolve(&self, link: &Link) -> Result<LinkResolution>
pub fn resolve(&self, link: &Link) -> Result<LinkResolution>
Resolve a link using the current time.
§Errors
Returns an error if the link is invalid, unavailable, expired, revoked, or has an invalid provider.
Sourcepub fn resolve_at(&self, link: &Link, now: u64) -> Result<LinkResolution>
pub fn resolve_at(&self, link: &Link, now: u64) -> Result<LinkResolution>
Resolve a link at an explicit timestamp.
§Errors
Returns an error if the link is invalid, unavailable, expired, revoked, or has an invalid provider.
Sourcepub fn resolve_version(
&self,
link: &NameLink,
version: &str,
) -> Result<LinkResolution>
pub fn resolve_version( &self, link: &NameLink, version: &str, ) -> Result<LinkResolution>
Resolve a mutable link to an exact semantic version.
§Errors
Returns an error if the link or requested version is unavailable.
Sourcepub fn resolve_with_options(
&self,
link: &Link,
options: &ResolveOptions,
) -> Result<LinkResolution>
pub fn resolve_with_options( &self, link: &Link, options: &ResolveOptions, ) -> Result<LinkResolution>
Resolve a link using explicit version and expiry options.
§Errors
Returns an error if the link is invalid, unavailable, expired, revoked, or has an invalid provider.
Sourcepub fn resolve_uri(&self, uri: &str) -> Result<LinkResolution>
pub fn resolve_uri(&self, uri: &str) -> Result<LinkResolution>
Parse and resolve a link URI.
§Errors
Returns an error if the URI cannot be parsed or the link cannot be resolved.
Sourcepub fn fetch_with_mirrors<T, Fetch>(
&self,
link: &Link,
fetch: Fetch,
) -> Result<T>
pub fn fetch_with_mirrors<T, Fetch>( &self, link: &Link, fetch: Fetch, ) -> Result<T>
Resolve and fetch a link, trying each provider and mirror in order.
§Errors
Returns the first successful fetch result, or an error if resolution fails or every provider fails.
Trait Implementations§
Source§impl Clone for LinkResolver
impl Clone for LinkResolver
Source§impl Debug for LinkResolver
impl Debug for LinkResolver
Auto Trait Implementations§
impl !RefUnwindSafe for LinkResolver
impl !UnwindSafe for LinkResolver
impl Freeze for LinkResolver
impl Send for LinkResolver
impl Sync for LinkResolver
impl Unpin for LinkResolver
impl UnsafeUnpin for LinkResolver
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more