|
|
|
@ -6,7 +6,8 @@ use async_trait::async_trait;
|
|
|
|
|
/// The `R` type is your resource repository (a database for instance) that will be passed to the
|
|
|
|
|
/// [`find`](Resolver::find) and [`endpoint`](Resolver::endpoint) functions.
|
|
|
|
|
#[async_trait]
|
|
|
|
|
pub trait Resolver<R> {
|
|
|
|
|
pub trait Resolver {
|
|
|
|
|
type Repo: Send;
|
|
|
|
|
/// Returns the domain name of the current instance.
|
|
|
|
|
async fn instance_domain<'a>(&self) -> &'a str;
|
|
|
|
|
|
|
|
|
@ -20,14 +21,14 @@ pub trait Resolver<R> {
|
|
|
|
|
&self,
|
|
|
|
|
prefix: Prefix,
|
|
|
|
|
acct: String,
|
|
|
|
|
resource_repo: R,
|
|
|
|
|
resource_repo: Self::Repo,
|
|
|
|
|
) -> Result<Webfinger, ResolverError>;
|
|
|
|
|
|
|
|
|
|
/// Returns a WebFinger result for a requested resource.
|
|
|
|
|
async fn endpoint(
|
|
|
|
|
&self,
|
|
|
|
|
resource: impl Into<String>,
|
|
|
|
|
resource_repo: R,
|
|
|
|
|
resource: impl Into<String> + Send,
|
|
|
|
|
resource_repo: Self::Repo,
|
|
|
|
|
) -> Result<Webfinger, ResolverError> {
|
|
|
|
|
let resource = resource.into();
|
|
|
|
|
let mut parsed_query = resource.splitn(2, ':');
|
|
|
|
|