sqlorm_core/
generic_row.rs

1/// Marker trait for types (primitives, tuples) intended for the generic Executor.
2///
3/// This trait acts as a positive compile-time check. The generic `Executor`
4/// implementation is constrained to types that implement `GenericRow`.
5///
6/// Application-specific models like `User` or `Post` which have their own
7/// custom executors should *not* implement this trait. This prevents the
8/// compiler from finding a conflicting implementation and ensures the more
9/// specific executor is chosen for those types.
10pub trait GenericRow {}
11
12impl GenericRow for String {}
13impl GenericRow for &str {}
14impl GenericRow for i8 {}
15impl GenericRow for i16 {}
16impl GenericRow for i32 {}
17impl GenericRow for i64 {}
18impl GenericRow for u8 {}
19impl GenericRow for u16 {}
20impl GenericRow for u32 {}
21impl GenericRow for u64 {}
22impl GenericRow for f32 {}
23impl GenericRow for f64 {}
24impl GenericRow for bool {}
25impl<T> GenericRow for Option<T> where T: GenericRow + Send {}
26
27// If you use other common crates, you can add implementations here under a feature flag.
28// #[cfg(feature = "chrono")]
29// impl GenericRow for chrono::NaiveDateTime {}
30#[cfg(feature = "uuid")]
31impl GenericRow for uuid::Uuid {}
32
33/// A macro to implement `GenericRow` for tuples of varying arity.
34macro_rules! impl_generic_row_for_tuples {
35    ($($T:ident),+) => {
36        impl<$($T: Send),+> GenericRow for ($($T,)+) {}
37    };
38}
39
40impl_generic_row_for_tuples!(T1);
41impl_generic_row_for_tuples!(T1, T2);
42impl_generic_row_for_tuples!(T1, T2, T3);
43impl_generic_row_for_tuples!(T1, T2, T3, T4);
44impl_generic_row_for_tuples!(T1, T2, T3, T4, T5);
45impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6);
46impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7);
47impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8);
48impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9);
49impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
50impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11);
51impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12);
52impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13);
53impl_generic_row_for_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14);
54impl_generic_row_for_tuples!(
55    T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
56);
57impl_generic_row_for_tuples!(
58    T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16
59);