pub trait Handler: Send + Sync {
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Handler trait for processing requests.
This is the core abstraction - all request handlers implement this trait. Handlers receive a request and produce a response or an error.
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles an HTTP request and produces a response.
§Errors
Returns an error if the request cannot be processed.
Implementations on Foreign Types§
Source§impl<T: Handler + ?Sized> Handler for Arc<T>
Blanket implementation for Arc<T> where T: Handler.
impl<T: Handler + ?Sized> Handler for Arc<T>
Blanket implementation for Arc<T> where T: Handler.
This allows Arc<dyn Handler> to be used as a Handler,
enabling shared ownership of handlers across threads.