request_pretreat/prefabs/
mod.rs1mod query;
2mod default_value;
3mod error_mapping;
4mod json;
5mod path;
6mod resp_result;
7
8use std::fmt::{Debug, Display};
9use std::marker::PhantomData;
10use std::ops::Deref;
11
12use actix_web::ResponseError;
13
14pub use self::default_value::DefaultValue;
15pub use self::error_mapping::{MapErrFut, MapError};
16pub use self::json::{JsonError, JsonPayload, JsonTreaterFut};
17pub use self::path::{PathError, PathValue};
18pub use self::query::QueryArgs;
19pub use self::resp_result::{ToRespResult, ToRespResultFut};
20
21struct RawError<T: ResponseError + 'static> {
22 raw: actix_web::Error,
23 _phantom: PhantomData<T>,
24}
25
26impl<T: ResponseError + 'static> Deref for RawError<T> {
27 type Target = T;
28 #[inline]
29 fn deref(&self) -> &Self::Target {
30 self.raw.as_error::<T>().unwrap()
31 }
32}
33
34impl<T: ResponseError + 'static> RawError<T> {
35 fn new(raw: actix_web::Error) -> Self {
36 Self {
37 raw,
38 _phantom: PhantomData,
39 }
40 }
41}
42
43impl<T: ResponseError + 'static> Display for RawError<T> {
44 #[inline]
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 std::fmt::Display::fmt(self.deref(), f)
47 }
48}
49impl<T: ResponseError + 'static> Debug for RawError<T> {
50 #[inline]
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 Debug::fmt(self.deref(), f)
53 }
54}