Skip to content

Commit e2e89cb

Browse files
committedMay 17, 2024
Retuns all PQconndefaults info
Fixes #45
1 parent 2cc3094 commit e2e89cb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
 

‎src/connection/info.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@ pub struct Info {
1010
}
1111

1212
impl Info {
13+
#[deprecated(since = "4.1.0", note = "Use Info::defaults() instead")]
14+
pub fn new() -> Self {
15+
Self::default()
16+
}
17+
1318
/**
1419
* Returns the default connection options.
1520
*
1621
* See [PQconndefaults](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNDEFAULTS)
1722
*/
18-
pub fn new() -> Self {
19-
Self::default()
23+
pub fn defaults() -> crate::errors::Result<Vec<Self>> {
24+
unsafe {
25+
let raw = pq_sys::PQconndefaults();
26+
let info = Self::vec_from_nta(raw);
27+
pq_sys::PQconninfoFree(raw);
28+
29+
info
30+
}
2031
}
2132

2233
/**
@@ -135,6 +146,6 @@ mod test {
135146

136147
#[test]
137148
fn defaults() {
138-
let _ = crate::connection::Info::default();
149+
let _ = crate::connection::Info::defaults();
139150
}
140151
}

0 commit comments

Comments
 (0)