mangadex_api/traits/
from_response.rs

1use mangadex_api_schema::error::MangaDexErrorResponse_ as MangaDexErrorResponse;
2use mangadex_api_schema::{
3    v5::Results, ApiData, ApiObject, ApiObjectNoRelationships, ApiResult, NoData,
4};
5use serde::de::DeserializeOwned;
6
7use super::FromResponse;
8
9impl FromResponse for NoData {
10    type Response = Self;
11    fn from_response(res: Self::Response) -> Self {
12        res
13    }
14}
15
16impl<T> FromResponse for Result<T, crate::error::Error> {
17    type Response = ApiResult<T, MangaDexErrorResponse>;
18
19    fn from_response(value: Self::Response) -> Self {
20        value.into_result().map_err(|e| e.into())
21    }
22}
23
24impl<T> FromResponse for Vec<Result<T, crate::error::Error>> {
25    type Response = Vec<ApiResult<T, MangaDexErrorResponse>>;
26
27    fn from_response(value: Self::Response) -> Self {
28        value
29            .into_iter()
30            .map(|r| r.into_result().map_err(|e| e.into()))
31            .collect()
32    }
33}
34
35impl<A> FromResponse for ApiObjectNoRelationships<A> {
36    type Response = Self;
37
38    fn from_response(value: Self::Response) -> Self {
39        value
40    }
41}
42
43impl<A> FromResponse for ApiObject<A> {
44    type Response = Self;
45
46    fn from_response(value: Self::Response) -> Self {
47        value
48    }
49}
50
51impl<T> FromResponse for ApiData<T>
52where
53    T: DeserializeOwned,
54{
55    type Response = Self;
56
57    fn from_response(value: Self::Response) -> Self {
58        value
59    }
60}
61
62impl<T> FromResponse for Results<T> {
63    type Response = Self;
64    fn from_response(res: Self::Response) -> Self {
65        res
66    }
67}
68
69impl FromResponse for mangadex_api_schema::v5::AtHomeServer {
70    type Response = Self;
71    fn from_response(res: Self::Response) -> Self {
72        res
73    }
74}
75
76impl FromResponse for mangadex_api_schema::v5::CheckUsernameAvailableResponse {
77    type Response = Self;
78
79    fn from_response(value: Self::Response) -> Self {
80        value
81    }
82}
83
84impl FromResponse for mangadex_api_schema::v5::oauth::OAuthTokenResponse {
85    type Response = Self;
86
87    fn from_response(res: Self::Response) -> Self {
88        res
89    }
90}
91
92impl FromResponse for mangadex_api_schema::v5::RefreshTokenResponse {
93    type Response = Self;
94
95    fn from_response(res: Self::Response) -> Self {
96        res
97    }
98}
99
100impl FromResponse for mangadex_api_schema::v5::upload_required_approval::UploadRequiredApproval {
101    type Response = Self;
102    fn from_response(res: Self::Response) -> Self {
103        res
104    }
105}
106
107impl FromResponse for mangadex_api_schema::v5::MangaStatisticsObject {
108    type Response = Self;
109
110    fn from_response(value: Self::Response) -> Self {
111        value
112    }
113}
114
115impl<A, T> FromResponse for mangadex_api_schema::v5::ForumThreadObject<A, T> {
116    type Response = Self;
117
118    fn from_response(value: Self::Response) -> Self {
119        value
120    }
121}
122
123impl<A> FromResponse for mangadex_api_schema::v5::UploadSessionFileData<A> {
124    type Response = Self;
125    fn from_response(res: Self::Response) -> Self {
126        res
127    }
128}