toolu_orm_core/row/
mod.rs1#[cfg(feature = "postgres")]
4mod decode_postgres;
5mod derived;
6#[cfg(feature = "postgres")]
7mod pg_count_scalar;
8mod traits;
9
10#[cfg(feature = "postgres")]
11pub use decode_postgres::from_postgres_row;
12#[cfg(feature = "postgres")]
13pub use pg_count_scalar::PgCountScalar;
14pub use traits::FromRow;
15
16#[macro_export]
20macro_rules! impl_from_row_for {
21 (single $cfg:meta, $ty:ty, $cols:expr, $method:ident, $row_ty:ty, $body:expr) => {
22 #[$cfg]
23 impl $crate::row::FromRow for $ty {
24 const REQUIRED_COLUMNS: &'static [&'static str] = $cols;
25 fn $method(row: &$row_ty) -> Result<Self, $crate::error::DbCoreError> {
26 $body(row)
27 }
28 }
29 };
30 (dual $cfg:meta, $ty:ty, $cols:expr,
31 [$m1:ident $r1:ty => $b1:expr],
32 [$m2:ident $r2:ty => $b2:expr]
33 ) => {
34 #[$cfg]
35 impl $crate::row::FromRow for $ty {
36 const REQUIRED_COLUMNS: &'static [&'static str] = $cols;
37 fn $m1(row: &$r1) -> Result<Self, $crate::error::DbCoreError> {
38 $b1(row)
39 }
40 fn $m2(row: &$r2) -> Result<Self, $crate::error::DbCoreError> {
41 $b2(row)
42 }
43 }
44 };
45 (triple $cfg:meta, $ty:ty, $cols:expr,
46 [$m1:ident $r1:ty => $b1:expr],
47 [$m2:ident $r2:ty => $b2:expr],
48 [$m3:ident $r3:ty => $b3:expr]
49 ) => {
50 #[$cfg]
51 impl $crate::row::FromRow for $ty {
52 const REQUIRED_COLUMNS: &'static [&'static str] = $cols;
53 fn $m1(row: &$r1) -> Result<Self, $crate::error::DbCoreError> {
54 $b1(row)
55 }
56 fn $m2(row: &$r2) -> Result<Self, $crate::error::DbCoreError> {
57 $b2(row)
58 }
59 fn $m3(row: &$r3) -> Result<Self, $crate::error::DbCoreError> {
60 $b3(row)
61 }
62 }
63 };
64}