Skip to main content

GenericClient

Trait GenericClient 

Source
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§

Source

fn prepare( &self, query: &str, ) -> impl Future<Output = Result<Statement, Error>> + Send

Source

fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<u64, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send,

Source

fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Row, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send,

Source

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,

Source

fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Vec<Row>, Error>> + Send
where T: ?Sized + ToStatement + Sync + Send,

Source

fn query_raw<T, I>( &self, statement: &T, params: I, ) -> impl Future<Output = Result<RowStream, Error>> + Send

Provided Methods§

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.

Implementations on Foreign Types§

Source§

impl GenericClient for Transaction<'_>

Source§

fn stmt_cache() -> bool

Source§

async fn prepare(&self, query: &str) -> Result<Statement, Error>

Source§

async fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_raw<T, I>( &self, statement: &T, params: I, ) -> Result<RowStream, Error>

Source§

impl GenericClient for Client

Source§

async fn prepare(&self, query: &str) -> Result<Statement, Error>

Source§

async fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_raw<T, I>( &self, statement: &T, params: I, ) -> Result<RowStream, Error>

Source§

impl GenericClient for Transaction<'_>

Source§

async fn prepare(&self, query: &str) -> Result<Statement, Error>

Source§

async fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_raw<T, I>( &self, statement: &T, params: I, ) -> Result<RowStream, Error>

Source§

impl GenericClient for Client

Source§

fn stmt_cache() -> bool

Source§

async fn prepare(&self, query: &str) -> Result<Statement, Error>

Source§

async fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
where T: ?Sized + ToStatement + Sync + Send,

Source§

async fn query_raw<T, I>( &self, statement: &T, params: I, ) -> Result<RowStream, Error>

Implementors§