synapse-rs 1.1.0

A standardized metric system (Vortex, Radiance, Axon) to evaluate real-world network quality beyond simple speed tests.
Documentation
//! Performance-only sample (wired Ethernet — no Wi-Fi fields).
//!
//! Run with: `cargo run --example vortex`
//! Optional JSON dump: `cargo run --example vortex --features serde`

use synapse_rs::{NetworkData, ScoreBand};

fn main() {
    let measure = NetworkData::new()
        .with_down_mbps(45.0)
        .with_up_mbps(12.0)
        .with_ping_ms(35.0)
        .with_jitter_ms(4.0)
        .with_packet_loss_percent(0.1);

    print_scores(&measure);

    #[cfg(feature = "serde")]
    if let Ok(json) = serde_json::to_string_pretty(&measure) {
        println!("\nStats (JSON):\n{json}");
    }
}

fn print_scores(measure: &NetworkData) {
    match measure.try_vortex() {
        Ok(v) => println!("Vortex   : {v:.2} ({})", ScoreBand::from_score(v)),
        Err(e) => println!("Vortex   : N/A ({e})"),
    }

    match measure.try_radiance() {
        Ok(r) => println!("Radiance : {r:.2}"),
        Err(e) => println!("Radiance : N/A ({e})"),
    }

    println!("--------------------");

    match measure.try_axon() {
        // On wired links Axon equals Vortex.
        Ok(a) => println!("AXON     : {a:.2} ({})", ScoreBand::from_score(a)),
        Err(e) => println!("AXON     : N/A ({e})"),
    }
}