lib/
db_commands.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::error::Error;
use std::fmt::Display;
use std::hash::Hash;

use sqlx::{Database, Pool};
use crate::utils::GenericError;

pub trait DbCommands: Default + Send + Sync
{
    type Key: Eq + Hash + Clone + Display + Send + Sync;
    type Value: Clone + Send + Sync;
    type Db: Database;

    async fn get(db_pool: &Pool<Self::Db>, key: &Self::Key) -> Option<Self::Value>;
    async fn put(db_pool: &Pool<Self::Db>, key: Self::Key, value: Self::Value) -> Result<(), GenericError>;
}