open-net 0.3.5

A cross-platform async networking library for Rust with HTTP and WebSocket clients, network status monitoring, configurable retries, WebSocket reconnection and heartbeats, and managed client lifecycles. Reuse common networking infrastructure across applications to avoid repeated implementation and debugging, helping save development time and AI coding tokens.
Documentation
//! Shared network monitoring with versioned snapshots and owned subscriptions.

mod events;
mod ip_stack;
mod names;
mod net_status_client;
mod network_status;
mod refresh;

pub use crate::module::net_status::inner::shared::NetworkStatusContext;
pub use crate::network::{
    LanInterfaceKind, LanIpv4Candidate, LanIpv4Completeness, LanIpv4Exclusion,
    LanIpv4RecommendationReason, LanIpv4Snapshot,
};
use crate::NetError;
pub use events::{NetworkEvent, NetworkEventKind, NetworkEventOptions, NetworkObservation};
pub use ip_stack::IpStack;
pub use names::{NetworkNameObserver, NetworkNameOptions, NetworkNameSnapshot, NetworkNameState};
pub use net_status_client::NetStatusClient;
pub use network_status::NetworkStatus;
pub use refresh::{NetworkIpStackSource, NetworkNameSource, NetworkRefreshResult};
use std::time::SystemTime;

/// One coherent observation, or an explicit state with no current observation.
#[derive(Clone, Debug)]
pub struct NetworkSnapshot {
    /// Monotonically increasing snapshot revision.
    pub revision: u64,
    /// Counter identifying the current loss/recovery epoch.
    pub loss_epoch: u64,
    /// Lifecycle state at the time of observation.
    pub state: MonitorState,
    /// Reachability observation, when one has been obtained.
    pub reachability: Option<NetworkStatus>,
    /// Locally available IP protocol stack, when known.
    pub ip_stack: Option<IpStack>,
    /// Timestamp at which the observation was collected.
    pub observed_at: Option<SystemTime>,
    /// Legacy compatibility field. SDK-produced connectivity snapshots always
    /// contain `None`. Use `NetStatusClient::observe_network_names` to explicitly
    /// observe names on a separate channel.
    pub network_name: Option<String>,
}

/// The lifecycle shared by every clone of a network status client.
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum MonitorState {
    /// Monitoring has not been started.
    Stopped,
    /// Monitoring startup is in progress.
    Starting,
    /// Monitoring is active and publishing observations.
    Running,
    /// Startup or monitoring failed; contains the classified cause.
    Failed(NetError),
    /// Monitoring was permanently shut down.
    Closed,
}