1use crate::decode::Decode;
2use crate::types::Type;
3
4#[cfg(feature = "postgres")]
5use crate::postgres::Postgres;
6
7#[cfg(feature = "mysql")]
8use crate::mysql::MySql;
9
10#[cfg(feature = "mssql")]
11use crate::mssql::Mssql;
12
13#[cfg(feature = "sqlite")]
14use crate::sqlite::Sqlite;
15
16macro_rules! impl_any_decode {
19 ($ty:ty) => {
20 impl<'r> crate::decode::Decode<'r, crate::any::Any> for $ty
21 where
22 $ty: crate::any::AnyDecode<'r>,
23 {
24 fn decode(
25 value: crate::any::AnyValueRef<'r>,
26 ) -> Result<Self, crate::error::BoxDynError> {
27 match value.kind {
28 #[cfg(feature = "mysql")]
29 crate::any::value::AnyValueRefKind::MySql(value) => {
30 <$ty as crate::decode::Decode<'r, crate::mysql::MySql>>::decode(value)
31 }
32
33 #[cfg(feature = "sqlite")]
34 crate::any::value::AnyValueRefKind::Sqlite(value) => {
35 <$ty as crate::decode::Decode<'r, crate::sqlite::Sqlite>>::decode(value)
36 }
37
38 #[cfg(feature = "mssql")]
39 crate::any::value::AnyValueRefKind::Mssql(value) => {
40 <$ty as crate::decode::Decode<'r, crate::mssql::Mssql>>::decode(value)
41 }
42
43 #[cfg(feature = "postgres")]
44 crate::any::value::AnyValueRefKind::Postgres(value) => {
45 <$ty as crate::decode::Decode<'r, crate::postgres::Postgres>>::decode(value)
46 }
47 }
48 }
49 }
50 };
51}
52
53#[cfg(all(
59 feature = "postgres",
60 feature = "mysql",
61 feature = "mssql",
62 feature = "sqlite"
63))]
64pub trait AnyDecode<'r>:
65 Decode<'r, Postgres>
66 + Type<Postgres>
67 + Decode<'r, MySql>
68 + Type<MySql>
69 + Decode<'r, Mssql>
70 + Type<Mssql>
71 + Decode<'r, Sqlite>
72 + Type<Sqlite>
73{
74}
75
76#[cfg(all(
77 feature = "postgres",
78 feature = "mysql",
79 feature = "mssql",
80 feature = "sqlite"
81))]
82impl<'r, T> AnyDecode<'r> for T where
83 T: Decode<'r, Postgres>
84 + Type<Postgres>
85 + Decode<'r, MySql>
86 + Type<MySql>
87 + Decode<'r, Mssql>
88 + Type<Mssql>
89 + Decode<'r, Sqlite>
90 + Type<Sqlite>
91{
92}
93
94#[cfg(all(
97 not(feature = "mssql"),
98 all(feature = "postgres", feature = "mysql", feature = "sqlite")
99))]
100pub trait AnyDecode<'r>:
101 Decode<'r, Postgres>
102 + Type<Postgres>
103 + Decode<'r, MySql>
104 + Type<MySql>
105 + Decode<'r, Sqlite>
106 + Type<Sqlite>
107{
108}
109
110#[cfg(all(
111 not(feature = "mssql"),
112 all(feature = "postgres", feature = "mysql", feature = "sqlite")
113))]
114impl<'r, T> AnyDecode<'r> for T where
115 T: Decode<'r, Postgres>
116 + Type<Postgres>
117 + Decode<'r, MySql>
118 + Type<MySql>
119 + Decode<'r, Sqlite>
120 + Type<Sqlite>
121{
122}
123
124#[cfg(all(
125 not(feature = "mysql"),
126 all(feature = "postgres", feature = "mssql", feature = "sqlite")
127))]
128pub trait AnyDecode<'r>:
129 Decode<'r, Postgres>
130 + Type<Postgres>
131 + Decode<'r, Mssql>
132 + Type<Mssql>
133 + Decode<'r, Sqlite>
134 + Type<Sqlite>
135{
136}
137
138#[cfg(all(
139 not(feature = "mysql"),
140 all(feature = "postgres", feature = "mssql", feature = "sqlite")
141))]
142impl<'r, T> AnyDecode<'r> for T where
143 T: Decode<'r, Postgres>
144 + Type<Postgres>
145 + Decode<'r, Mssql>
146 + Type<Mssql>
147 + Decode<'r, Sqlite>
148 + Type<Sqlite>
149{
150}
151
152#[cfg(all(
153 not(feature = "sqlite"),
154 all(feature = "postgres", feature = "mysql", feature = "mssql")
155))]
156pub trait AnyDecode<'r>:
157 Decode<'r, Postgres>
158 + Type<Postgres>
159 + Decode<'r, MySql>
160 + Type<MySql>
161 + Decode<'r, Mssql>
162 + Type<Mssql>
163{
164}
165
166#[cfg(all(
167 not(feature = "sqlite"),
168 all(feature = "postgres", feature = "mysql", feature = "mssql")
169))]
170impl<'r, T> AnyDecode<'r> for T where
171 T: Decode<'r, Postgres>
172 + Type<Postgres>
173 + Decode<'r, MySql>
174 + Type<MySql>
175 + Decode<'r, Mssql>
176 + Type<Mssql>
177{
178}
179
180#[cfg(all(
181 not(feature = "postgres"),
182 all(feature = "sqlite", feature = "mysql", feature = "mssql")
183))]
184pub trait AnyDecode<'r>:
185 Decode<'r, Sqlite>
186 + Type<Sqlite>
187 + Decode<'r, MySql>
188 + Type<MySql>
189 + Decode<'r, Mssql>
190 + Type<Mssql>
191{
192}
193
194#[cfg(all(
195 not(feature = "postgres"),
196 all(feature = "sqlite", feature = "mysql", feature = "mssql")
197))]
198impl<'r, T> AnyDecode<'r> for T where
199 T: Decode<'r, Sqlite>
200 + Type<Sqlite>
201 + Decode<'r, MySql>
202 + Type<MySql>
203 + Decode<'r, Mssql>
204 + Type<Mssql>
205{
206}
207
208#[cfg(all(
211 not(any(feature = "mssql", feature = "sqlite")),
212 all(feature = "postgres", feature = "mysql")
213))]
214pub trait AnyDecode<'r>:
215 Decode<'r, Postgres> + Type<Postgres> + Decode<'r, MySql> + Type<MySql>
216{
217}
218
219#[cfg(all(
220 not(any(feature = "mssql", feature = "sqlite")),
221 all(feature = "postgres", feature = "mysql")
222))]
223impl<'r, T> AnyDecode<'r> for T where
224 T: Decode<'r, Postgres> + Type<Postgres> + Decode<'r, MySql> + Type<MySql>
225{
226}
227
228#[cfg(all(
229 not(any(feature = "mysql", feature = "sqlite")),
230 all(feature = "postgres", feature = "mssql")
231))]
232pub trait AnyDecode<'r>:
233 Decode<'r, Postgres> + Type<Postgres> + Decode<'r, Mssql> + Type<Mssql>
234{
235}
236
237#[cfg(all(
238 not(any(feature = "mysql", feature = "sqlite")),
239 all(feature = "postgres", feature = "mssql")
240))]
241impl<'r, T> AnyDecode<'r> for T where
242 T: Decode<'r, Postgres> + Type<Postgres> + Decode<'r, Mssql> + Type<Mssql>
243{
244}
245
246#[cfg(all(
247 not(any(feature = "mysql", feature = "mssql")),
248 all(feature = "postgres", feature = "sqlite")
249))]
250pub trait AnyDecode<'r>:
251 Decode<'r, Postgres> + Type<Postgres> + Decode<'r, Sqlite> + Type<Sqlite>
252{
253}
254
255#[cfg(all(
256 not(any(feature = "mysql", feature = "mssql")),
257 all(feature = "postgres", feature = "sqlite")
258))]
259impl<'r, T> AnyDecode<'r> for T where
260 T: Decode<'r, Postgres> + Type<Postgres> + Decode<'r, Sqlite> + Type<Sqlite>
261{
262}
263
264#[cfg(all(
265 not(any(feature = "postgres", feature = "sqlite")),
266 all(feature = "mssql", feature = "mysql")
267))]
268pub trait AnyDecode<'r>: Decode<'r, Mssql> + Type<Mssql> + Decode<'r, MySql> + Type<MySql> {}
269
270#[cfg(all(
271 not(any(feature = "postgres", feature = "sqlite")),
272 all(feature = "mssql", feature = "mysql")
273))]
274impl<'r, T> AnyDecode<'r> for T where
275 T: Decode<'r, Mssql> + Type<Mssql> + Decode<'r, MySql> + Type<MySql>
276{
277}
278
279#[cfg(all(
280 not(any(feature = "postgres", feature = "mysql")),
281 all(feature = "mssql", feature = "sqlite")
282))]
283pub trait AnyDecode<'r>:
284 Decode<'r, Mssql> + Type<Mssql> + Decode<'r, Sqlite> + Type<Sqlite>
285{
286}
287
288#[cfg(all(
289 not(any(feature = "postgres", feature = "mysql")),
290 all(feature = "mssql", feature = "sqlite")
291))]
292impl<'r, T> AnyDecode<'r> for T where
293 T: Decode<'r, Mssql> + Type<Mssql> + Decode<'r, Sqlite> + Type<Sqlite>
294{
295}
296
297#[cfg(all(
298 not(any(feature = "postgres", feature = "mssql")),
299 all(feature = "mysql", feature = "sqlite")
300))]
301pub trait AnyDecode<'r>:
302 Decode<'r, MySql> + Type<MySql> + Decode<'r, Sqlite> + Type<Sqlite>
303{
304}
305
306#[cfg(all(
307 not(any(feature = "postgres", feature = "mssql")),
308 all(feature = "mysql", feature = "sqlite")
309))]
310impl<'r, T> AnyDecode<'r> for T where
311 T: Decode<'r, MySql> + Type<MySql> + Decode<'r, Sqlite> + Type<Sqlite>
312{
313}
314
315#[cfg(all(
318 not(any(feature = "mysql", feature = "mssql", feature = "sqlite")),
319 feature = "postgres"
320))]
321pub trait AnyDecode<'r>: Decode<'r, Postgres> + Type<Postgres> {}
322
323#[cfg(all(
324 not(any(feature = "mysql", feature = "mssql", feature = "sqlite")),
325 feature = "postgres"
326))]
327impl<'r, T> AnyDecode<'r> for T where T: Decode<'r, Postgres> + Type<Postgres> {}
328
329#[cfg(all(
330 not(any(feature = "postgres", feature = "mssql", feature = "sqlite")),
331 feature = "mysql"
332))]
333pub trait AnyDecode<'r>: Decode<'r, MySql> + Type<MySql> {}
334
335#[cfg(all(
336 not(any(feature = "postgres", feature = "mssql", feature = "sqlite")),
337 feature = "mysql"
338))]
339impl<'r, T> AnyDecode<'r> for T where T: Decode<'r, MySql> + Type<MySql> {}
340
341#[cfg(all(
342 not(any(feature = "mysql", feature = "postgres", feature = "sqlite")),
343 feature = "mssql"
344))]
345pub trait AnyDecode<'r>: Decode<'r, Mssql> + Type<Mssql> {}
346
347#[cfg(all(
348 not(any(feature = "mysql", feature = "postgres", feature = "sqlite")),
349 feature = "mssql"
350))]
351impl<'r, T> AnyDecode<'r> for T where T: Decode<'r, Mssql> + Type<Mssql> {}
352
353#[cfg(all(
354 not(any(feature = "mysql", feature = "mssql", feature = "postgres")),
355 feature = "sqlite"
356))]
357pub trait AnyDecode<'r>: Decode<'r, Sqlite> + Type<Sqlite> {}
358
359#[cfg(all(
360 not(any(feature = "mysql", feature = "mssql", feature = "postgres")),
361 feature = "sqlite"
362))]
363impl<'r, T> AnyDecode<'r> for T where T: Decode<'r, Sqlite> + Type<Sqlite> {}