-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathstructs.rs
More file actions
50 lines (44 loc) · 1.02 KB
/
structs.rs
File metadata and controls
50 lines (44 loc) · 1.02 KB
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
use std::sync::Arc;
use deadpool_postgres::Object;
use tokio_postgres::{Client, Config};
#[derive(Debug)]
pub struct PoolConnection {
pub connection: Object,
pub in_transaction: bool,
pub in_cursor: bool,
pub pg_config: Arc<Config>,
}
impl PoolConnection {
#[must_use]
pub fn new(connection: Object, pg_config: Arc<Config>) -> Self {
Self {
connection,
in_transaction: false,
in_cursor: false,
pg_config,
}
}
}
#[derive(Debug)]
pub struct SingleConnection {
pub connection: Client,
pub in_transaction: bool,
pub in_cursor: bool,
pub pg_config: Arc<Config>,
}
impl SingleConnection {
#[must_use]
pub fn new(connection: Client, pg_config: Arc<Config>) -> Self {
Self {
connection,
in_transaction: false,
in_cursor: false,
pg_config,
}
}
}
#[derive(Debug)]
pub enum PSQLPyConnection {
PoolConn(PoolConnection),
SingleConnection(SingleConnection),
}