Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 693cf06

Browse files
conradludgatepimeys
authored andcommitted
get type generic client
1 parent 5316117 commit 693cf06

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 {}
@@ -79,6 +80,9 @@ pub trait GenericClient: private::Sealed {
7980
/// Like `Client::batch_execute`.
8081
async fn batch_execute(&self, query: &str) -> Result<(), Error>;
8182

83+
/// Query for type information
84+
async fn get_type(&self, oid: Oid) -> Result<Type, Error>;
85+
8286
/// Returns a reference to the underlying `Client`.
8387
fn client(&self) -> &Client;
8488
}
@@ -173,6 +177,11 @@ impl GenericClient for Client {
173177
Ok(())
174178
}
175179

180+
/// Query for type information
181+
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
182+
self.get_type(oid).await
183+
}
184+
176185
fn client(&self) -> &Client {
177186
self
178187
}
@@ -270,6 +279,11 @@ impl GenericClient for Transaction<'_> {
270279
Ok(())
271280
}
272281

282+
/// Query for type information
283+
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
284+
self.client().get_type(oid).await
285+
}
286+
273287
fn client(&self) -> &Client {
274288
self.client()
275289
}

0 commit comments

Comments
 (0)