From e1ac3881734293cb33674a8b0b1d983132b9c2b1 Mon Sep 17 00:00:00 2001 From: "Boris.Lok" <77889460+boris-lok@users.noreply.github.com> Date: Tue, 24 Oct 2023 07:48:41 +0800 Subject: [PATCH] Provide `fn PgConnectOptions::get_host(&self)` (#2752) Co-authored-by: boris --- sqlx-postgres/src/options/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sqlx-postgres/src/options/mod.rs b/sqlx-postgres/src/options/mod.rs index 3a9e617c57..90621f4e80 100644 --- a/sqlx-postgres/src/options/mod.rs +++ b/sqlx-postgres/src/options/mod.rs @@ -205,6 +205,20 @@ impl PgConnectOptions { self } + /// Get the current host. + /// + /// # Example + /// + /// ```rust + /// # use sqlx_core::postgres::PgConnectOptions; + /// let options = PgConnectOptions::new() + /// .host("127.0.0.1"); + /// assert_eq!(options.get_host(), "127.0.0.1"); + /// ``` + pub fn get_host(&self) -> &str { + self.host.as_str() + } + /// Sets the port to connect to at the server host. /// /// The default port for PostgreSQL is `5432`.