Skip to content

Commit 50fa995

Browse files
committed
Reorder a bit
1 parent a8ac31a commit 50fa995

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

tokio-postgres/src/generic_client.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ mod private {
1212
/// This trait is "sealed", and cannot be implemented outside of this crate.
1313
#[async_trait]
1414
pub trait GenericClient: private::Sealed {
15-
/// Get a reference to the underlying `Client`
16-
fn client(&self) -> &Client;
17-
1815
/// Like `Client::execute`.
1916
async fn execute<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
2017
where
@@ -71,16 +68,15 @@ pub trait GenericClient: private::Sealed {
7168

7269
/// Like `Client::transaction`.
7370
async fn transaction(&mut self) -> Result<Transaction<'_>, Error>;
71+
72+
/// Returns a reference to the underlying `Client`.
73+
fn client(&self) -> &Client;
7474
}
7575

7676
impl private::Sealed for Client {}
7777

7878
#[async_trait]
7979
impl GenericClient for Client {
80-
fn client(&self) -> &Client {
81-
self
82-
}
83-
8480
async fn execute<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
8581
where
8682
T: ?Sized + ToStatement + Sync + Send,
@@ -152,17 +148,17 @@ impl GenericClient for Client {
152148
async fn transaction(&mut self) -> Result<Transaction<'_>, Error> {
153149
self.transaction().await
154150
}
151+
152+
fn client(&self) -> &Client {
153+
self
154+
}
155155
}
156156

157157
impl private::Sealed for Transaction<'_> {}
158158

159159
#[async_trait]
160160
#[allow(clippy::needless_lifetimes)]
161161
impl GenericClient for Transaction<'_> {
162-
fn client(&self) -> &Client {
163-
self.client()
164-
}
165-
166162
async fn execute<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
167163
where
168164
T: ?Sized + ToStatement + Sync + Send,
@@ -235,4 +231,8 @@ impl GenericClient for Transaction<'_> {
235231
async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error> {
236232
self.transaction().await
237233
}
234+
235+
fn client(&self) -> &Client {
236+
self.client()
237+
}
238238
}

tokio-postgres/src/transaction.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ impl<'a> Transaction<'a> {
6464
}
6565
}
6666

67-
/// Get a reference to the underlying `Client`
68-
pub fn client(&self) -> &Client {
69-
&self.client
70-
}
71-
7267
/// Consumes the transaction, committing all changes made within it.
7368
pub async fn commit(mut self) -> Result<(), Error> {
7469
self.done = true;
@@ -311,4 +306,9 @@ impl<'a> Transaction<'a> {
311306
done: false,
312307
})
313308
}
309+
310+
/// Returns a reference to the underlying `Client`.
311+
pub fn client(&self) -> &Client {
312+
&self.client
313+
}
314314
}

0 commit comments

Comments
 (0)