Skip to content

Commit

Permalink
Expose PoolOptions in SharedPool
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Jun 10, 2022
1 parent 20d61f4 commit 1599574
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sqlx-core/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ impl<DB: Database> Pool<DB> {
pub fn num_idle(&self) -> usize {
self.0.num_idle()
}

/// Get the connection options for this pool
pub fn connect_options(&self) -> &<DB::Connection as Connection>::Options {
&self.0.connect_options
}
}

#[cfg(all(
Expand Down
14 changes: 14 additions & 0 deletions sqlx-core/src/postgres/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ impl PgConnectOptions {
self
}

/// Get the current database name.
///
/// # Example
///
/// ```rust
/// # use sqlx_core::postgres::PgConnectOptions;
/// let options = PgConnectOptions::new()
/// .database("postgres");
/// assert!(options.get_database().is_some());
/// ```
pub fn get_database(&self) -> Option<&str> {
self.database.as_deref()
}

/// Sets whether or with what priority a secure SSL TCP/IP connection will be negotiated
/// with the server.
///
Expand Down

0 comments on commit 1599574

Please sign in to comment.