use crate::error::Result;
use crate::row::{Row, SimpleQueryMessage};
use crate::types::ToSql;
use crate::Connection;
#[allow(async_fn_in_trait)]
pub trait GenericClient {
async fn query(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>>;
async fn query_one(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Row>;
async fn query_opt(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)])
-> Result<Option<Row>>;
async fn execute(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<u64>;
async fn simple_query(&mut self, sql: &str) -> Result<Vec<SimpleQueryMessage>>;
}
impl GenericClient for Connection {
async fn query(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>> {
Connection::query(self, sql, params).await
}
async fn query_one(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Row> {
Connection::query_one(self, sql, params).await
}
async fn query_opt(
&mut self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<Option<Row>> {
Connection::query_opt(self, sql, params).await
}
async fn execute(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<u64> {
Connection::execute(self, sql, params).await
}
async fn simple_query(&mut self, sql: &str) -> Result<Vec<SimpleQueryMessage>> {
Connection::simple_query(self, sql).await
}
}
impl GenericClient for crate::PooledConnection {
async fn query(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>> {
Connection::query(self, sql, params).await
}
async fn query_one(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Row> {
Connection::query_one(self, sql, params).await
}
async fn query_opt(
&mut self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<Option<Row>> {
Connection::query_opt(self, sql, params).await
}
async fn execute(&mut self, sql: &str, params: &[&(dyn ToSql + Sync)]) -> Result<u64> {
Connection::execute(self, sql, params).await
}
async fn simple_query(&mut self, sql: &str) -> Result<Vec<SimpleQueryMessage>> {
Connection::simple_query(self, sql).await
}
}