Expand description
day-part-network — a HEADLESS cross-platform network-connectivity API. No UI; any Rust code can
depend on this crate and call status for a snapshot of the device’s connectivity through the
platform’s NATIVE API.
if let Some(n) = day_part_network::status() {
println!("online: {}, kind: {:?}", n.online, n.kind);
}Platform selection is purely #[cfg(target_os)]/#[cfg(target_env)] (connectivity is an OS
concern, not a widget-toolkit one): macOS and iOS share one SCNetworkReachability file, Windows
uses GetNetworkConnectivityHint, Linux scans /sys/class/net, HarmonyOS the native
libnet_connection.so, and Android ConnectivityManager (via a Java shim staged by day build).
Platforms without a connectivity API return None.
Every field is best-effort — each OS reports a different slice of the truth. kind and
expensive in particular vary per platform (macOS reachability carries no transport info, Linux
infers the kind from interface names, only Android/HarmonyOS report meteredness); see the
per-field docs and docs/network.md for the honest per-platform matrix.
Structs§
- Network
Status - A snapshot of the device’s network connectivity.
Enums§
- Network
Kind - The transport class of the active network connection. Best-effort — not every platform can
distinguish these (see
NetworkStatus::kind).
Functions§
- status
- Read a connectivity snapshot via the platform’s native API. Returns
Nonewhen there is no connectivity API on the platform (or the reading failed) — distinct from a successful reading that says offline (Somewithonline: false).