1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
*
* Copyright (c) 2025-2026 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//! A module containing various types for managing Ethernet, Thread and Wifi networks.
use Future;
pub use GenericNetifs as SysNetifs;
/// A platform-appropriate alias for the default OS-backed `NetifDiag` /
/// `NetChangeNotif` implementation:
///
/// - On Unix (non-ESP-IDF) it resolves to [`unix::UnixNetifs`], which uses
/// `nix` and reports MAC addresses and link-local IPv6 addresses.
/// - On other platforms (notably Windows) it resolves to
/// [`generic::GenericNetifs`], a portable `if-addrs`-backed fallback that
/// does not report MAC addresses.
pub use UnixNetifs as SysNetifs;
/// A generic trait for network change notifications.
/// Polling interval used by the polling-based [`NetChangeNotif`]
/// implementations of [`unix::UnixNetifs`] and [`generic::GenericNetifs`].
pub const NETIF_POLL_INTERVAL: Duration = from_secs;
/// A polling-based [`NetChangeNotif::wait_changed`] helper that simply waits
/// for [`NETIF_POLL_INTERVAL`] and then unconditionally reports a change.
///
/// This intentionally does NOT compare interface snapshots itself, because:
/// - A snapshot-comparing helper would only observe changes that happen
/// while it is being awaited; any change occurring between two consecutive
/// `wait_changed` calls would be missed.
/// - Callers of [`NetChangeNotif`] are expected to re-read the interface
/// state after `wait_changed` returns and diff it against the previously
/// observed state, so doing the same diff inside `wait_changed` would be
/// redundant.
///
/// The trade-off is that callers will be woken up every
/// [`NETIF_POLL_INTERVAL`] even when nothing has changed; for an OS-level
/// `NetChangeNotif`, [`NETIF_POLL_INTERVAL`] should therefore be kept large
/// enough to keep that overhead negligible.
pub async