pub trait GenericClient: Send + Sync {
// Required methods
fn prepare(
&self,
query: &str,
) -> impl Future<Output = Result<Statement, Error>> + Send;
fn execute<T>(
&self,
query: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<u64, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send;
fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Row, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send;
fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Option<Row>, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send;
fn query<T>(
&self,
query: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Vec<Row>, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send;
fn query_raw<T, I>(
&self,
statement: &T,
params: I,
) -> impl Future<Output = Result<RowStream, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send,
I: IntoIterator + Sync + Send,
I::IntoIter: ExactSizeIterator,
I::Item: BorrowToSql;
// Provided method
fn stmt_cache() -> bool { ... }
}Expand description
Abstraction over multiple types of asynchronous clients. This allows you to use tokio_postgres clients and transactions interchangeably.
In addition, when the deadpool feature is enabled (default), this trait also
abstracts over deadpool clients and transactions
Required Methods§
fn prepare( &self, query: &str, ) -> impl Future<Output = Result<Statement, Error>> + Send
fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<u64, Error>> + Send
fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Row, Error>> + Send
fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Option<Row>, Error>> + Send
fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Vec<Row>, Error>> + Send
fn query_raw<T, I>(
&self,
statement: &T,
params: I,
) -> impl Future<Output = Result<RowStream, Error>> + Sendwhere
T: ?Sized + ToStatement + Sync + Send,
I: IntoIterator + Sync + Send,
I::IntoIter: ExactSizeIterator,
I::Item: BorrowToSql,
Provided Methods§
fn stmt_cache() -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.