use mysql_async::Pool; use async_trait::async_trait; use crate::Response; use crate::UBigInt; #[macro_export] macro_rules! no_conn { ($spec:literal) => { format!("[ CON Error ] : {}", $spec) } } #[macro_export] macro_rules! sql_err { ($spec:literal) => { format!("[ SQL Error ] : {}", $spec) } } #[macro_export] macro_rules! sql_err_log { ($spec:expr) => { println!($spec); } } /* * NOTE: pay attention to work on async in traits for rust * Each of one these funcs will implicitly do a single heap allocation which * for our case is fine though ideally we don't * * As soon as we finda way around that we should depecrate `#[async_trait` * for the performance * */ #[async_trait] pub trait FromDB { type Row; async fn get(p: &Pool, id: UBigInt) -> Response; async fn update(p: &Pool, row: T) -> Response; async fn delete(p: &Pool, id: UBigInt) -> Response; async fn filter(p: &Pool, filter_val: FilterType) -> Response; }