pub trait Resolver {
type State: FromRequest + 'static;
type Error: ResponseError + 'static;
// Required method
fn find(
scheme: Option<&str>,
account: &str,
domain: &str,
state: Self::State,
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>>;
}Expand description
A trait to ease the implementation of Webfinger Resolvers
ⓘ
use actix_webfinger::{Resolver, Webfinger};
use std::{future::Future, pin::Pin};
struct MyResolver;
impl Resolver for MyResolver {
type State = ();
type Error = CustomError;
fn find(
account: &str,
domain: &str,
_state: Self::State,
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>> {
let webfinger = Webfinger::new(&format!("{}@{}", account, domain));
// do something
Box::pin(async move { Ok(Some(webfinger)) })
}
}
#[actix_rt::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
HttpServer::new(|| {
App::new()
.data(())
.service(resource::<MyResolver>())
})
.bind("127.0.0.1:8000")?
.run()
.await?;
Ok(())
}Required Associated Types§
type State: FromRequest + 'static
type Error: ResponseError + 'static
Required Methods§
fn find( scheme: Option<&str>, account: &str, domain: &str, state: Self::State, ) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.