viz_core/handler/
map_into_response.rs1use crate::{Handler, IntoResponse, Response, Result};
2
3#[derive(Clone, Debug)]
5pub struct MapInToResponse<H>(pub(crate) H);
6
7impl<H> MapInToResponse<H> {
8 #[inline]
10 pub const fn new(h: H) -> Self {
11 Self(h)
12 }
13}
14
15#[crate::async_trait]
16impl<H, I, O> Handler<I> for MapInToResponse<H>
17where
18 I: Send + 'static,
19 H: Handler<I, Output = Result<O>>,
20 O: IntoResponse,
21{
22 type Output = Result<Response>;
23
24 async fn call(&self, i: I) -> Self::Output {
25 self.0.call(i).await.map(IntoResponse::into_response)
26 }
27}