Skip to content

Commit

Permalink
🎨 Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGariepy committed Jun 12, 2022
1 parent aa95c65 commit ee5419e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
31 changes: 15 additions & 16 deletions cornucopia_client/src/async_.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use async_trait::async_trait;
use tokio_postgres::{
types::BorrowToSql, Client as PgClient, Error, RowStream, Statement, ToStatement,
Transaction as PgTransaction,
types::BorrowToSql, Client, Error, RowStream, Statement, ToStatement, Transaction,
};

#[async_trait]
Expand Down Expand Up @@ -45,9 +44,9 @@ pub trait GenericClient {
}

#[async_trait]
impl GenericClient for PgTransaction<'_> {
impl GenericClient for Transaction<'_> {
async fn prepare(&self, query: &str) -> Result<Statement, Error> {
PgTransaction::prepare(self, query).await
Transaction::prepare(self, query).await
}

async fn execute<T>(
Expand All @@ -58,7 +57,7 @@ impl GenericClient for PgTransaction<'_> {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgTransaction::execute(self, query, params).await
Transaction::execute(self, query, params).await
}

async fn query_one<T>(
Expand All @@ -69,7 +68,7 @@ impl GenericClient for PgTransaction<'_> {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgTransaction::query_one(self, statement, params).await
Transaction::query_one(self, statement, params).await
}

async fn query_opt<T>(
Expand All @@ -80,7 +79,7 @@ impl GenericClient for PgTransaction<'_> {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgTransaction::query_opt(self, statement, params).await
Transaction::query_opt(self, statement, params).await
}

async fn query<T>(
Expand All @@ -91,7 +90,7 @@ impl GenericClient for PgTransaction<'_> {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgTransaction::query(self, query, params).await
Transaction::query(self, query, params).await
}

async fn query_raw<T, P, I>(&self, statement: &T, params: I) -> Result<RowStream, Error>
Expand All @@ -101,14 +100,14 @@ impl GenericClient for PgTransaction<'_> {
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
{
PgTransaction::query_raw(self, statement, params).await
Transaction::query_raw(self, statement, params).await
}
}

#[async_trait]
impl GenericClient for PgClient {
impl GenericClient for Client {
async fn prepare(&self, query: &str) -> Result<Statement, Error> {
PgClient::prepare(self, query).await
Client::prepare(self, query).await
}

async fn execute<T>(
Expand All @@ -119,7 +118,7 @@ impl GenericClient for PgClient {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgClient::execute(self, query, params).await
Client::execute(self, query, params).await
}

async fn query_one<T>(
Expand All @@ -130,7 +129,7 @@ impl GenericClient for PgClient {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgClient::query_one(self, statement, params).await
Client::query_one(self, statement, params).await
}

async fn query_opt<T>(
Expand All @@ -141,7 +140,7 @@ impl GenericClient for PgClient {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgClient::query_opt(self, statement, params).await
Client::query_opt(self, statement, params).await
}

async fn query<T>(
Expand All @@ -152,7 +151,7 @@ impl GenericClient for PgClient {
where
T: ?Sized + tokio_postgres::ToStatement + Sync + Send,
{
PgClient::query(self, query, params).await
Client::query(self, query, params).await
}

async fn query_raw<T, P, I>(&self, statement: &T, params: I) -> Result<RowStream, Error>
Expand All @@ -162,6 +161,6 @@ impl GenericClient for PgClient {
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
{
PgClient::query_raw(self, statement, params).await
Client::query_raw(self, statement, params).await
}
}
4 changes: 2 additions & 2 deletions cornucopia_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod array_iterator;
#[cfg(feature = "async")]
mod async_;
#[cfg(feature = "deadpool")]
mod deadpool;
#[doc(hidden)]
pub mod private;

pub use array_iterator::ArrayIterator;
#[cfg(feature = "async")]
pub use async_::GenericClient;
#[cfg(feature = "deadpool")]
mod deadpool;

0 comments on commit ee5419e

Please sign in to comment.