Skip to content

Commit d8f8fad

Browse files
committed
Add passfile_paths setter method
1 parent 39b2f67 commit d8f8fad

File tree

1 file changed

+18
-0
lines changed
  • sqlx-postgres/src/options

1 file changed

+18
-0
lines changed

sqlx-postgres/src/options/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::borrow::Cow;
22
use std::env::var;
3+
use std::ffi::OsStr;
34
use std::fmt::{self, Display, Write};
45
use std::path::{Path, PathBuf};
56

@@ -187,6 +188,23 @@ impl PgConnectOptions {
187188
self
188189
}
189190

191+
/// Sets the paths to try when looking for the pgpass file.
192+
///
193+
/// # Example
194+
///
195+
/// ```rust
196+
/// # use sqlx_postgres::PgConnectOptions;
197+
/// let options = PgConnectOptions::new()
198+
/// .passfile_paths(&["/non/default/pgpass"]);
199+
/// ```
200+
pub fn passfile_paths<P>(mut self, paths: impl IntoIterator<Item = P>) -> Self
201+
where
202+
P: Into<PathBuf> + AsRef<OsStr>,
203+
{
204+
self.passfile_paths = paths.into_iter().map(Into::into).collect();
205+
self
206+
}
207+
190208
/// Sets the database name. Defaults to be the same as the user name.
191209
///
192210
/// # Example

0 commit comments

Comments
 (0)