sqlx_cache/
db_commands.rs

1use std::error::Error;
2use std::fmt::Display;
3use std::hash::Hash;
4
5use sqlx::{Database, Pool};
6use crate::utils::GenericError;
7
8pub trait DbCommands: Default + Send + Sync
9{
10    type Key: Eq + Hash + Clone + Display + Send + Sync;
11    type Value: Clone + Send + Sync;
12    type Db: Database;
13
14    async fn get(db_pool: &Pool<Self::Db>, key: &Self::Key) -> Option<Self::Value>;
15    async fn put(db_pool: &Pool<Self::Db>, key: Self::Key, value: Self::Value) -> Result<(), GenericError>;
16}