Skip to content

Commit 5ce7a89

Browse files
fixups
1 parent 30773fc commit 5ce7a89

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

netwatch/src/interfaces/linux.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub enum Error {
2323
MissingDestinationField,
2424
#[error("mask field is missing")]
2525
MissingMaskField,
26+
#[error("netlink")]
27+
Netlink(#[from] rtnetlink::Error),
2628
}
2729

2830
pub async fn default_route() -> Option<DefaultRouteDetails> {

netwatch/src/netmon/actor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
};
66

77
use futures_lite::future::Boxed as BoxFuture;
8+
pub(super) use os::Error;
89
use os::{is_interesting_interface, RouteMonitor};
910
use tokio::sync::{mpsc, oneshot};
1011
use tracing::{debug, trace};
@@ -28,8 +29,6 @@ use crate::{
2829
ip::is_link_local,
2930
};
3031

31-
pub(super) use os::Error;
32-
3332
/// The message sent by the OS specific monitors.
3433
#[derive(Debug, Copy, Clone)]
3534
pub(super) enum NetworkMessage {

netwatch/src/netmon/windows.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ pub(super) struct RouteMonitor {
2222
pub enum Error {
2323
#[error("IO {0}")]
2424
Io(#[from] std::io::Error),
25-
NotifyUnicastIpAddressChange(#[from] WIN32_ERROR),
25+
#[error("win32: {0}")]
26+
Win32(#[from] windows::Win32::Foundation::Error),
2627
}
2728

2829
impl RouteMonitor {
@@ -112,7 +113,8 @@ impl CallbackHandler {
112113
Some(Arc::as_ptr(&cb) as *const c_void), // context
113114
BOOLEAN::from(false), // initial notification,
114115
&mut handle,
115-
)?;
116+
)
117+
.ok()?;
116118
}
117119

118120
self.unicast_callbacks.insert(handle.0 as isize, cb);
@@ -131,7 +133,8 @@ impl CallbackHandler {
131133
.is_some()
132134
{
133135
unsafe {
134-
windows::Win32::NetworkManagement::IpHelper::CancelMibChangeNotify2(handle.0)?;
136+
windows::Win32::NetworkManagement::IpHelper::CancelMibChangeNotify2(handle.0)
137+
.ok()?;
135138
}
136139
}
137140

@@ -152,7 +155,8 @@ impl CallbackHandler {
152155
Arc::as_ptr(&cb) as *const c_void, // context
153156
BOOLEAN::from(false), // initial notification,
154157
&mut handle,
155-
)?;
158+
)
159+
.ok()?;
156160
}
157161

158162
self.route_callbacks.insert(handle.0 as isize, cb);
@@ -171,7 +175,8 @@ impl CallbackHandler {
171175
.is_some()
172176
{
173177
unsafe {
174-
windows::Win32::NetworkManagement::IpHelper::CancelMibChangeNotify2(handle.0)?;
178+
windows::Win32::NetworkManagement::IpHelper::CancelMibChangeNotify2(handle.0)
179+
.ok()?;
175180
}
176181
}
177182

netwatch/src/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ impl Drop for UdpSocket {
814814

815815
#[cfg(test)]
816816
mod tests {
817-
use super::*;
818-
819817
use testresult::TestResult;
820818

819+
use super::*;
820+
821821
#[tokio::test]
822822
async fn test_reconnect() -> TestResult {
823823
let (s_b, mut r_b) = tokio::sync::mpsc::channel(16);

0 commit comments

Comments
 (0)