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