From f4f279764184be04364e26dcc0f8698587d0c7a7 Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Thu, 18 Jan 2024 12:14:07 +1300 Subject: [PATCH] Add get_port to PgConnectionOptions --- sqlx-postgres/src/options/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sqlx-postgres/src/options/mod.rs b/sqlx-postgres/src/options/mod.rs index 2da782841c..32509aa9ef 100644 --- a/sqlx-postgres/src/options/mod.rs +++ b/sqlx-postgres/src/options/mod.rs @@ -235,6 +235,19 @@ impl PgConnectOptions { self } + /// Get the current port. + /// + /// # Example + /// + /// ```rust + /// # use sqlx_postgres::PgConnectOptions; + /// let options = PgConnectOptions::new(); + /// assert_eq!(options.get_port(), 5432); + /// ``` + pub fn get_port(&self) -> u16 { + self.port + } + /// Sets a custom path to a directory containing a unix domain socket, /// switching the connection method from TCP to the corresponding socket. ///