Skip to content

Commit

Permalink
refactor(core): deprecate PgConnectionInfo
Browse files Browse the repository at this point in the history
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
  • Loading branch information
AtkinsChang committed Aug 18, 2021
1 parent 207e6db commit ffc72ff
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sqlx-core/src/postgres/connection/mod.rs
Expand Up @@ -65,6 +65,11 @@ pub struct PgConnection {
}

impl PgConnection {
/// the version number of the server in `libpq` format
pub fn server_version_num(&self) -> Option<u32> {
self.stream.server_version_num
}

// will return when the connection is ready for another query
async fn wait_until_ready(&mut self) -> Result<(), Error> {
if !self.stream.wbuf.is_empty() {
Expand Down Expand Up @@ -178,19 +183,24 @@ impl Connection for PgConnection {
}
}

#[deprecated(since = "0.5.7")]
pub trait PgConnectionInfo {
/// the version number of the server in `libpq` format
#[deprecated(
since = "0.5.7",
note = "please use `server_version_num` from impl instead"
)]
fn server_version_num(&self) -> Option<u32>;
}

impl PgConnectionInfo for PgConnection {
fn server_version_num(&self) -> Option<u32> {
self.stream.server_version_num
self.server_version_num()
}
}

impl PgConnectionInfo for crate::pool::PoolConnection<Postgres> {
fn server_version_num(&self) -> Option<u32> {
self.stream.server_version_num
self.server_version_num()
}
}

0 comments on commit ffc72ff

Please sign in to comment.