Skip to content

Commit

Permalink
Retuns all PQconndefaults info
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
sanpii committed May 17, 2024
1 parent 2cc3094 commit e2e89cb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/connection/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@ pub struct Info {
}

impl Info {
#[deprecated(since = "4.1.0", note = "Use Info::defaults() instead")]
pub fn new() -> Self {
Self::default()
}

/**
* Returns the default connection options.
*
* See [PQconndefaults](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNDEFAULTS)
*/
pub fn new() -> Self {
Self::default()
pub fn defaults() -> crate::errors::Result<Vec<Self>> {
unsafe {
let raw = pq_sys::PQconndefaults();
let info = Self::vec_from_nta(raw);
pq_sys::PQconninfoFree(raw);

info
}
}

/**
Expand Down Expand Up @@ -135,6 +146,6 @@ mod test {

#[test]
fn defaults() {
let _ = crate::connection::Info::default();
let _ = crate::connection::Info::defaults();
}
}

0 comments on commit e2e89cb

Please sign in to comment.