Skip to content

Commit ce7260d

Browse files
committed
get type generic client
1 parent b502452 commit ce7260d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tokio-postgres/src/generic_client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::query::RowStream;
22
use crate::types::{BorrowToSql, ToSql, Type};
33
use crate::{Client, Error, Row, Statement, ToStatement, Transaction};
44
use async_trait::async_trait;
5+
use postgres_protocol::Oid;
56

67
mod private {
78
pub trait Sealed {}
@@ -76,6 +77,9 @@ pub trait GenericClient: private::Sealed {
7677
/// Like `Client::transaction`.
7778
async fn transaction(&mut self) -> Result<Transaction<'_>, Error>;
7879

80+
/// Query for type information
81+
async fn get_type(&self, oid: Oid) -> Result<Type, Error>;
82+
7983
/// Returns a reference to the underlying `Client`.
8084
fn client(&self) -> &Client;
8185
}
@@ -165,6 +169,11 @@ impl GenericClient for Client {
165169
self.transaction().await
166170
}
167171

172+
/// Query for type information
173+
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
174+
self.get_type(oid).await
175+
}
176+
168177
fn client(&self) -> &Client {
169178
self
170179
}
@@ -257,6 +266,11 @@ impl GenericClient for Transaction<'_> {
257266
self.transaction().await
258267
}
259268

269+
/// Query for type information
270+
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
271+
self.client().get_type(oid).await
272+
}
273+
260274
fn client(&self) -> &Client {
261275
self.client()
262276
}

0 commit comments

Comments
 (0)