Expose connect_options for initialized pools and database on the PgConnectOptions (#1897)

* Expose ConnectOptions

* Expose PoolOptions
This commit is contained in:
Arne Beer 2022-06-16 21:25:13 +02:00 committed by GitHub
parent 664d576655
commit 21590d51f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -435,6 +435,16 @@ 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
}
/// Get the options for this pool
pub fn options(&self) -> &PoolOptions<DB> {
&self.0.options
}
}
#[cfg(all(

View File

@ -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.
///