Skip to content

Commit e52ba3d

Browse files
committed
Split getter to unix and not unix systems
Signed-off-by: chandr-andr (Kiselev Aleksandr) <[email protected]>
1 parent 617da8b commit e52ba3d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/driver/connection.rs

+19
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl Connection {
8989
host_addrs_vec
9090
}
9191

92+
#[cfg(unix)]
9293
#[getter]
9394
fn hosts(&self) -> Vec<String> {
9495
let mut hosts_vec = vec![];
@@ -108,6 +109,24 @@ impl Connection {
108109
hosts_vec
109110
}
110111

112+
#[cfg(not(unix))]
113+
#[getter]
114+
fn hosts(&self) -> Vec<String> {
115+
let mut hosts_vec = vec![];
116+
117+
let hosts = self.pg_config.get_hosts();
118+
for host in hosts {
119+
match host {
120+
Host::Tcp(host) => {
121+
hosts_vec.push(host.to_string());
122+
}
123+
_ => unreachable!(),
124+
}
125+
}
126+
127+
hosts_vec
128+
}
129+
111130
#[getter]
112131
fn ports(&self) -> Vec<&u16> {
113132
return self.pg_config.get_ports().iter().collect::<Vec<&u16>>();

src/driver/cursor.rs

+19
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ impl Cursor {
160160
host_addrs_vec
161161
}
162162

163+
#[cfg(unix)]
163164
#[getter]
164165
fn hosts(&self) -> Vec<String> {
165166
let mut hosts_vec = vec![];
@@ -179,6 +180,24 @@ impl Cursor {
179180
hosts_vec
180181
}
181182

183+
#[cfg(not(unix))]
184+
#[getter]
185+
fn hosts(&self) -> Vec<String> {
186+
let mut hosts_vec = vec![];
187+
188+
let hosts = self.pg_config.get_hosts();
189+
for host in hosts {
190+
match host {
191+
Host::Tcp(host) => {
192+
hosts_vec.push(host.to_string());
193+
}
194+
_ => unreachable!(),
195+
}
196+
}
197+
198+
hosts_vec
199+
}
200+
182201
#[getter]
183202
fn ports(&self) -> Vec<&u16> {
184203
return self.pg_config.get_ports().iter().collect::<Vec<&u16>>();

src/driver/transaction.rs

+19
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl Transaction {
190190
host_addrs_vec
191191
}
192192

193+
#[cfg(unix)]
193194
#[getter]
194195
fn hosts(&self) -> Vec<String> {
195196
let mut hosts_vec = vec![];
@@ -209,6 +210,24 @@ impl Transaction {
209210
hosts_vec
210211
}
211212

213+
#[cfg(not(unix))]
214+
#[getter]
215+
fn hosts(&self) -> Vec<String> {
216+
let mut hosts_vec = vec![];
217+
218+
let hosts = self.pg_config.get_hosts();
219+
for host in hosts {
220+
match host {
221+
Host::Tcp(host) => {
222+
hosts_vec.push(host.to_string());
223+
}
224+
_ => unreachable!(),
225+
}
226+
}
227+
228+
hosts_vec
229+
}
230+
212231
#[getter]
213232
fn ports(&self) -> Vec<&u16> {
214233
return self.pg_config.get_ports().iter().collect::<Vec<&u16>>();

0 commit comments

Comments
 (0)