netwatch-sdk 0.1.0

Shared wire-format types and collectors for NetWatch Cloud — the SDK consumed by netwatch-agent and the NetWatch Cloud server. Parses /proc, ss, lsof, nettop, and libpcap events into a common Snapshot payload.
Documentation
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
use anyhow::Result;
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct InterfaceStats {
    pub name: String,
    pub rx_bytes: u64,
    pub tx_bytes: u64,
    pub rx_packets: u64,
    pub tx_packets: u64,
    pub rx_errors: u64,
    pub tx_errors: u64,
    pub rx_drops: u64,
    pub tx_drops: u64,
    pub is_up: bool,
}

#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
pub use linux::collect_interface_stats;

#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
pub use macos::collect_interface_stats;

#[cfg(not(any(target_os = "linux", target_os = "macos")))]
pub fn collect_interface_stats() -> Result<HashMap<String, InterfaceStats>> {
    Ok(HashMap::new())
}