1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use crate::error::C3p0Error;
pub trait C3p0Pool: Clone {
type CONN;
fn connection(&self) -> Result<Self::CONN, C3p0Error>;
fn transaction<T, E: From<C3p0Error>, F: FnOnce(&mut Self::CONN) -> Result<T, E>>(
&self,
tx: F,
) -> Result<T, E>;
}
pub trait SqlConnection {
fn batch_execute(&mut self, sql: &str) -> Result<(), C3p0Error>;
}
#[cfg(feature = "async")]
use async_trait::async_trait;
#[cfg(feature = "async")]
use std::future::Future;
#[cfg(feature = "async")]
use std::pin::Pin;
#[cfg(feature = "async")]
#[async_trait]
pub trait C3p0PoolAsync: Clone {
type CONN;
async fn transaction<
T: Send + Sync,
E: From<C3p0Error>,
F: Send + FnOnce(&mut Self::CONN) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + '_>>,
>(
&self,
tx: F,
)
-> Result<T, E>;
}
#[cfg(feature = "async")]
#[async_trait]
pub trait SqlConnectionAsync {
async fn batch_execute(&mut self, sql: &str) -> Result<(), C3p0Error>;
}