Skip to content

Commit a865207

Browse files
committed
Rename to GenericClient
1 parent 6deef22 commit a865207

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

postgres/src/client.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
CancelToken, Config, CopyInWriter, CopyOutReader, GenericConnection, RowIter, Statement,
2+
CancelToken, Config, CopyInWriter, CopyOutReader, GenericClient, RowIter, Statement,
33
ToStatement, Transaction,
44
};
55
use std::ops::{Deref, DerefMut};
@@ -494,22 +494,25 @@ impl Client {
494494
}
495495
}
496496

497-
impl GenericConnection for Client {
497+
impl GenericClient for Client {
498498
fn execute<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
499499
where
500500
T: ?Sized + ToStatement,
501501
{
502502
self.execute(query, params)
503503
}
504+
504505
fn query<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error>
505506
where
506507
T: ?Sized + ToStatement,
507508
{
508509
self.query(query, params)
509510
}
511+
510512
fn prepare(&mut self, query: &str) -> Result<Statement, Error> {
511513
self.prepare(query)
512514
}
515+
513516
fn transaction(&mut self) -> Result<Transaction<'_>, Error> {
514517
self.transaction()
515518
}

postgres/src/generic_connection.rs renamed to postgres/src/generic_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use tokio_postgres::types::ToSql;
33
use tokio_postgres::{Error, Row};
44

55
/// A trait allowing abstraction over connections and transactions
6-
pub trait GenericConnection {
6+
pub trait GenericClient {
77
/// Like `Client::execute`.
88
fn execute<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
99
where

postgres/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use crate::copy_in_writer::CopyInWriter;
6161
pub use crate::copy_out_reader::CopyOutReader;
6262
#[doc(no_inline)]
6363
pub use crate::error::Error;
64-
pub use crate::generic_connection::GenericConnection;
64+
pub use crate::generic_client::GenericClient;
6565
#[doc(no_inline)]
6666
pub use crate::row::{Row, SimpleQueryRow};
6767
pub use crate::row_iter::RowIter;
@@ -75,7 +75,7 @@ mod client;
7575
pub mod config;
7676
mod copy_in_writer;
7777
mod copy_out_reader;
78-
mod generic_connection;
78+
mod generic_client;
7979
mod lazy_pin;
8080
mod row_iter;
8181
mod transaction;

postgres/src/transaction.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
CancelToken, CopyInWriter, CopyOutReader, GenericConnection, Portal, RowIter, Rt, Statement,
2+
CancelToken, CopyInWriter, CopyOutReader, GenericClient, Portal, RowIter, Rt, Statement,
33
ToStatement,
44
};
55
use tokio::runtime::Runtime;
@@ -186,22 +186,25 @@ impl<'a> Transaction<'a> {
186186
}
187187
}
188188

189-
impl<'a> GenericConnection for Transaction<'a> {
189+
impl<'a> GenericClient for Transaction<'a> {
190190
fn execute<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
191191
where
192192
T: ?Sized + ToStatement,
193193
{
194194
self.execute(query, params)
195195
}
196+
196197
fn query<T>(&mut self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error>
197198
where
198199
T: ?Sized + ToStatement,
199200
{
200201
self.query(query, params)
201202
}
203+
202204
fn prepare(&mut self, query: &str) -> Result<Statement, Error> {
203205
self.prepare(query)
204206
}
207+
205208
fn transaction(&mut self) -> Result<Transaction<'_>, Error> {
206209
self.transaction()
207210
}

0 commit comments

Comments
 (0)