
also reworked error messages so they create Strings and dont use `&'static str`'s anymore
40 lines
853 B
Rust
40 lines
853 B
Rust
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)
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 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<T> {
|
|
type Row;
|
|
|
|
async fn get(p: &Pool, id: UBigInt) -> Response<T>;
|
|
|
|
async fn update(p: &Pool, row: T) -> Response<T>;
|
|
|
|
async fn delete(p: &Pool, id: UBigInt) -> Response<T>;
|
|
}
|