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<T> {
    type Row;

    async fn get(p: &Pool, id: UBigInt) -> Response<T>;

    async fn update(p: &Pool, row: T) -> Response<T>;
}
