Skip to main content

AsyncRequestHandler

Trait AsyncRequestHandler 

Source
pub trait AsyncRequestHandler: Send + Sync {
    // Required method
    fn handle<'req>(
        &'req self,
        request: &'req mut Request,
    ) -> Pin<Box<dyn Future<Output = Result<Response, HttpError>> + Send + 'req>>;
}
Expand description

Async controller: turns a request into a response.

Required Methods§

Source

fn handle<'req>( &'req self, request: &'req mut Request, ) -> Pin<Box<dyn Future<Output = Result<Response, HttpError>> + Send + 'req>>

Handles request.

§Errors

Returns HttpError when the handler cannot produce a response.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> AsyncRequestHandler for AsyncFn<F>
where F: for<'req> Fn(&'req mut Request) -> Pin<Box<dyn Future<Output = Result<Response, HttpError>> + Send + 'req>> + Send + Sync,

Source§

impl<H> AsyncRequestHandler for SyncToAsync<H>
where H: RequestHandler,