Skip to content

Commit

Permalink
get type generic client
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Nov 2, 2023
1 parent b502452 commit ce7260d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tokio-postgres/src/generic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::query::RowStream;
use crate::types::{BorrowToSql, ToSql, Type};
use crate::{Client, Error, Row, Statement, ToStatement, Transaction};
use async_trait::async_trait;
use postgres_protocol::Oid;

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

/// Query for type information
async fn get_type(&self, oid: Oid) -> Result<Type, Error>;

/// Returns a reference to the underlying `Client`.
fn client(&self) -> &Client;
}
Expand Down Expand Up @@ -165,6 +169,11 @@ impl GenericClient for Client {
self.transaction().await
}

/// Query for type information
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
self.get_type(oid).await
}

fn client(&self) -> &Client {
self
}
Expand Down Expand Up @@ -257,6 +266,11 @@ impl GenericClient for Transaction<'_> {
self.transaction().await
}

/// Query for type information
async fn get_type(&self, oid: Oid) -> Result<Type, Error> {
self.client().get_type(oid).await
}

fn client(&self) -> &Client {
self.client()
}
Expand Down

0 comments on commit ce7260d

Please sign in to comment.