diff --git a/server-api/db/src/common.rs b/server-api/db/src/common.rs new file mode 100644 index 0000000..41f8c30 --- /dev/null +++ b/server-api/db/src/common.rs @@ -0,0 +1,25 @@ +use mysql_async::Pool; +use async_trait::async_trait; + +use crate::Response; +use crate::UBigInt; + +pub const NO_CONN_MSG: &'static str = "No connection could be established"; + +/* + * 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; +}