forked from rust-postgres/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneric_client.rs
More file actions
21 lines (17 loc) · 727 Bytes
/
Copy pathgeneric_client.rs
File metadata and controls
21 lines (17 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::types::ToSql;
use crate::{Error, Row, Statement, ToStatement, Transaction};
/// A trait allowing abstraction over connections and transactions.
pub trait GenericClient {
/// Like `Client::execute`.
fn execute<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
where
T: ?Sized + ToStatement;
/// Like `Client::query`.
fn query<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error>
where
T: ?Sized + ToStatement;
/// Like `Client::prepare`.
fn prepare(&mut self, query: &str) -> Result<Statement, Error>;
/// Like `Client::transaction`.
fn transaction(&mut self) -> Result<Transaction<'_>, Error>;
}