viz_core/handler/
into_handler.rs1use crate::{FnExt, FromRequest, Handler, IntoResponse, Result, handler::FnExtHandler};
2
3pub trait IntoHandler<I, E> {
5 type Handler: Handler<I>;
7
8 #[must_use]
10 fn into_handler(self) -> Self::Handler;
11}
12
13impl<I, H, E, O> IntoHandler<I, E> for H
14where
15 I: Send + 'static,
16 E: FromRequest + 'static,
17 E::Error: IntoResponse,
18 H: FnExt<I, E, Output = Result<O>>,
19 O: 'static,
20{
21 type Handler = FnExtHandler<H, E, O>;
22
23 fn into_handler(self) -> Self::Handler {
24 FnExtHandler::new(self)
25 }
26}