noosphere_into/resolver/
resolver_implementation.rs

1use crate::ResolvedLink;
2use anyhow::Result;
3use async_trait::async_trait;
4use subtext::Slashlink;
5
6#[cfg(not(target_arch = "wasm32"))]
7pub trait ResolverConditionalSendSync: Send + Sync {}
8
9#[cfg(not(target_arch = "wasm32"))]
10impl<S> ResolverConditionalSendSync for S where S: Send + Sync {}
11
12#[cfg(target_arch = "wasm32")]
13pub trait ResolverConditionalSendSync {}
14
15#[cfg(target_arch = "wasm32")]
16impl<S> ResolverConditionalSendSync for S {}
17
18/// A [Resolver] is given a [Slashlink] and resolves it to a [ResolvedLink]
19/// which includes an href, which is a URL string that can be used to link
20/// to the content referred to by the [Slashlink] over the hypertext web.
21#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
22#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
23pub trait Resolver: Clone + ResolverConditionalSendSync {
24    async fn resolve(&self, link: &Slashlink) -> Result<ResolvedLink>;
25}