This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
ood_persistence/src/asyn.rs

30 lines
695 B
Rust
Raw Normal View History

2021-10-12 18:14:02 +03:00
use crate::error;
#[async_trait]
pub trait PersistencePool: Send + Sync {
type Conn: ConnectionClient;
async fn get_connection(&self) -> error::Result<Self::Conn>;
}
2021-10-17 15:08:46 +03:00
#[cfg_attr(feature = "nightly", async_trait)]
2021-10-12 18:14:02 +03:00
pub trait ConnectionClient {
type InnerConn;
2021-10-17 15:08:46 +03:00
#[cfg(feature = "nightly")]
type Trx<'t>: TransactionClient;
2021-10-12 18:14:02 +03:00
fn inner(&mut self) -> &mut Self::InnerConn;
2021-10-17 15:08:46 +03:00
#[cfg(feature = "nightly")]
async fn start_transaction(&mut self) -> error::Result<Self::Trx<'_>>;
}
#[cfg(feature = "nightly")]
#[async_trait]
pub trait TransactionClient: ConnectionClient {
async fn commit(self) -> error::Result<()>;
async fn rollback(self) -> error::Result<()>;
2021-10-12 18:14:02 +03:00
}