Skip to main content

SettingsFn

Trait SettingsFn 

Source
pub trait SettingsFn<'a>:
    Send
    + Sync
    + 'static {
    type Fut: Future<Output = Settings<'static, 'static>> + Send + 'a;

    // Required method
    fn call(&self, conn: &'a Conn) -> Self::Fut;
}
Expand description

An async function from &Conn to Settings, as accepted by HtmlRewriter::new_async.

This trait is implemented for any async closure or async fn that takes a &Conn and returns Settings<'static, 'static>, as well as for plain closures that return such a future. The lifetime parameter allows the future to borrow the Conn across .await points; because of that, the bound in HtmlRewriter::new_async is the higher-ranked F: for<'a> SettingsFn<'a>.

You should not need to implement or name this trait directly — write one of the closure forms documented on HtmlRewriter::new_async.

Required Associated Types§

Source

type Fut: Future<Output = Settings<'static, 'static>> + Send + 'a

The future returned by call.

Required Methods§

Source

fn call(&self, conn: &'a Conn) -> Self::Fut

Build the Settings that will rewrite the response on this [Conn].

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, F, Fut> SettingsFn<'a> for F
where F: Fn(&'a Conn) -> Fut + Send + Sync + 'static, Fut: Future<Output = Settings<'static, 'static>> + Send + 'a,

Source§

type Fut = Fut