fire_http/into/
route_result.rs1use super::IntoResponse;
2use crate::error::{ClientErrorKind, Error};
3use crate::Response;
4
5pub trait IntoRouteResult {
6 fn into_route_result(self) -> crate::Result<Response>;
7}
8
9impl<R, E> IntoRouteResult for Result<R, E>
10where
11 R: IntoResponse,
12 E: Into<Error>,
13{
14 fn into_route_result(self) -> crate::Result<Response> {
15 self.map(|o| o.into_response()).map_err(|e| e.into())
16 }
17}
18
19impl<R> IntoRouteResult for Option<R>
20where
21 R: IntoResponse,
22{
23 fn into_route_result(self) -> crate::Result<Response> {
24 match self {
25 Some(r) => Ok(r.into_response()),
26 None => Err(Error::empty(ClientErrorKind::NotFound)),
27 }
28 }
29}
30
31impl<R> IntoRouteResult for R
32where
33 R: IntoResponse,
34{
35 fn into_route_result(self) -> crate::Result<Response> {
36 Ok(self.into_response())
37 }
38}