wae_database/orm/
macros.rs1#[macro_export]
7macro_rules! entity_fields {
8 ($($name:ident: $type:ty),* $(,)?) => {
9 $(pub $name: $type,)*
10 };
11}
12
13#[macro_export]
15macro_rules! impl_to_row {
16 ($type:ty { $($col:literal => $field:ident),* $(,)? }) => {
17 impl ToRow for $type {
18 fn to_row(&self) -> Vec<(&'static str, wae_types::Value)> {
19 vec![
20 $((col, self.$field.clone().into()),)*
21 ]
22 }
23 }
24 };
25}
26
27#[macro_export]
29macro_rules! impl_from_row {
30 ($type:ty { $($idx:literal => $field:ident: $ftype:ty),* $(,)? }) => {
31 impl FromRow for $type {
32 fn from_row(row: &$crate::DatabaseRow) -> $crate::DatabaseResult<Self> {
33 Ok(Self {
34 $($field: row.get::<$ftype>($idx)?,)*
35 })
36 }
37 }
38 };
39}