Skip to content

Commit 42f5c4b

Browse files
committed
Use Bool::as_bool() to convert to Rust bool
1 parent 865112d commit 42f5c4b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

nym-vpn-core/crates/nym-apple-network/src/path.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Path {
4444
pub fn uses_interface_type(&self, interface_type: InterfaceType) -> bool {
4545
unsafe {
4646
sys::nw_path_uses_interface_type(self.inner.as_mut_ptr(), interface_type.as_raw())
47-
== Bool::YES
47+
.as_bool()
4848
}
4949
}
5050

@@ -90,34 +90,34 @@ impl Path {
9090

9191
/// Checks whether the path can route IPv4 traffic.
9292
pub fn supports_ipv4(&self) -> bool {
93-
unsafe { sys::nw_path_has_ipv4(self.inner.as_mut_ptr()) == Bool::YES }
93+
unsafe { sys::nw_path_has_ipv4(self.inner.as_mut_ptr()).as_bool() }
9494
}
9595

9696
/// Checks whether the path can route IPv6 traffic.
9797
pub fn supports_ipv6(&self) -> bool {
98-
unsafe { sys::nw_path_has_ipv6(self.inner.as_mut_ptr()) == Bool::YES }
98+
unsafe { sys::nw_path_has_ipv6(self.inner.as_mut_ptr()).as_bool() }
9999
}
100100

101101
/// Checks whether the path has a DNS server configured.
102102
pub fn supports_dns(&self) -> bool {
103-
unsafe { sys::nw_path_has_dns(self.inner.as_mut_ptr()) == Bool::YES }
103+
unsafe { sys::nw_path_has_dns(self.inner.as_mut_ptr()).as_bool() }
104104
}
105105

106106
/// Checks whether the path uses an interface in Low Data Mode.
107107
pub fn is_constrained(&self) -> bool {
108-
unsafe { sys::nw_path_is_constrained(self.inner.as_mut_ptr()) == Bool::YES }
108+
unsafe { sys::nw_path_is_constrained(self.inner.as_mut_ptr()).as_bool() }
109109
}
110110

111111
/// Checks whether the path uses an interface that is considered expensive, such as Cellular or a Personal Hotspot.
112112
pub fn is_expensive(&self) -> bool {
113-
unsafe { sys::nw_path_is_expensive(self.inner.as_mut_ptr()) == Bool::YES }
113+
unsafe { sys::nw_path_is_expensive(self.inner.as_mut_ptr()).as_bool() }
114114
}
115115
}
116116

117117
impl PartialEq for Path {
118118
fn eq(&self, other: &Self) -> bool {
119119
unsafe {
120-
sys::nw_path_is_equal(self.inner.as_mut_ptr(), other.inner.as_mut_ptr()) == Bool::YES
120+
sys::nw_path_is_equal(self.inner.as_mut_ptr(), other.inner.as_mut_ptr()).as_bool()
121121
}
122122
}
123123
}

nym-vpn-core/crates/nym-apple-network/src/sys.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ create_opaque_type!(OS_nw_endpoint, nw_endpoint_t);
4949
pub type nw_path_monitor_update_handler_t = block2::Block<dyn Fn(nw_path_t)>;
5050
pub type nw_path_monitor_cancel_handler_t = block2::Block<dyn Fn()>;
5151
pub type nw_path_status_t = c_int;
52-
pub type nw_path_enumerate_interfaces_block_t =
53-
block2::Block<dyn Fn(nw_interface_t) -> objc2::runtime::Bool>;
54-
pub type nw_path_enumerate_gateways_block_t =
55-
block2::Block<dyn Fn(nw_endpoint_t) -> objc2::runtime::Bool>;
52+
pub type nw_path_enumerate_interfaces_block_t = block2::Block<dyn Fn(nw_interface_t) -> Bool>;
53+
pub type nw_path_enumerate_gateways_block_t = block2::Block<dyn Fn(nw_endpoint_t) -> Bool>;
5654

5755
pub type nw_path_status_type_t = c_int;
5856
pub const nw_path_status_invalid: nw_path_status_type_t = 0;

0 commit comments

Comments
 (0)