use rocket::figment::Figment;
#[rocket::async_trait]
pub trait Pool: Sized + Send + Sync + 'static {
type Connection;
type Error: std::error::Error;
async fn init(figment: &Figment) -> Result<Self, Self::Error>;
fn borrow(&self) -> &Self::Connection;
}
#[derive(Debug)]
pub struct MockPool;
#[derive(Debug)]
pub struct MockPoolErr;
impl std::fmt::Display for MockPoolErr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for MockPoolErr {}
#[rocket::async_trait]
impl Pool for MockPool {
type Error = MockPoolErr;
type Connection = bool;
async fn init(_figment: &Figment) -> Result<Self, Self::Error> {
Ok(MockPool)
}
fn borrow(&self) -> &Self::Connection {
&true
}
}