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
//! Network configuration and local-address discovery helpers.
use crateNetError;
use Ipv4Addr;
pub use ;
pub use crate;
/// Select a LAN IPv4 using the original compatibility heuristic.
///
/// Preserves its subnet/name filters and 192.168 > 10 > 172.16/12 ordering;
/// ties keep OS enumeration order. It does not inspect native link/type/route
/// evidence and can prefer an inactive bridge reported as operational up.
/// Use [`lan_ipv4_snapshot`] for evidence-based selection and full diagnostics.
/// None means no candidate passed this policy, not proof of no usable network.
/// Synchronously collect local IPv4 candidates and an explainable recommendation.
///
/// Does not require an engine, runtime, monitor, or Internet access. Blocks the
/// caller while querying the OS; no remote probe is sent. Prefer a blocking
/// worker when integrating into an async or UI application.
///
/// Enumeration failure returns Err with the original I/O error. A successful
/// empty inventory is Ok; auxiliary metadata failures produce a Partial result
/// with candidates and diagnostics. Such a result must not be used as proof that
/// a previously healthy application's endpoint disappeared.
///
/// Native interface/link/default-route evidence precedes address preference;
/// the three private IPv4 ranges are equally ranked. Excluded VPN/CGNAT and
/// other addresses remain visible for application-specific selection. The
/// recommendation is not a guarantee of reachability, successful binding, or
/// an atomic view of the OS. No monitoring event or cached snapshot is changed.
///
/// ```no_run
/// # fn main() -> open_net::Result<()> {
/// let lan = open_net::network::lan_ipv4_snapshot()?;
/// for candidate in lan.candidates() {
/// println!("{} {}: {:?}", candidate.interface_name(), candidate.address(),
/// candidate.default_exclusions());
/// }
/// if let Some(selected) = lan.recommended() {
/// println!("recommended {}: {:?}", selected.address(), selected.recommendation_reason());
/// }
/// # Ok(()) }
/// ```