IntoHandler

Trait IntoHandler 

Source
pub trait IntoHandler<Args>:
    Clone
    + Send
    + Sync
    + 'static {
    type Handler: Handler;

    // Required method
    fn into_handler(self) -> Self::Handler;
}
Expand description

Trait for converting various function types into handlers.

This enables ergonomic handler registration:

router.get("/", my_handler);  // Works for any IntoHandler

Required Associated Types§

Source

type Handler: Handler

The handler type this converts into.

Required Methods§

Source

fn into_handler(self) -> Self::Handler

Convert into a handler.

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.

Implementors§

Source§

impl<F, Fut> IntoHandler<(HttpRequest,)> for F
where F: Fn(HttpRequest) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Result<HttpResponse, Error>> + Send + 'static,

Implement IntoHandler for async functions.