#[macro_export]
macro_rules! entity_fields {
($($name:ident: $type:ty),* $(,)?) => {
$(pub $name: $type,)*
};
}
#[macro_export]
macro_rules! impl_to_row {
($type:ty { $($col:literal => $field:ident),* $(,)? }) => {
impl ToRow for $type {
fn to_row(&self) -> Vec<(&'static str, wae_types::Value)> {
vec![
$((col, self.$field.clone().into()),)*
]
}
}
};
}
#[macro_export]
macro_rules! impl_from_row {
($type:ty { $($idx:literal => $field:ident: $ftype:ty),* $(,)? }) => {
impl FromRow for $type {
fn from_row(row: &$crate::DatabaseRow) -> $crate::DatabaseResult<Self> {
Ok(Self {
$($field: row.get::<$ftype>($idx)?,)*
})
}
}
};
}