Skip to content

Commit

Permalink
Provide fn PgConnectOptions::get_host(&self) (#2752)
Browse files Browse the repository at this point in the history
Co-authored-by: boris <boris.lok@cienet.com>
  • Loading branch information
boris-lok and boris authored Oct 23, 2023
1 parent ba87bf7 commit e1ac388
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sqlx-postgres/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit e1ac388

Please sign in to comment.