<h1 align="center">Synapse</h1>
<p align="center">
<a href="https://crates.io/crates/synapse-rs"><img alt="Crates.io" src="https://img.shields.io/crates/v/synapse-rs"></a>
<a href="https://crates.io/crates/synapse-rs"><img alt="Downloads" src="https://img.shields.io/crates/d/synapse-rs"></a>
<a href="https://docs.rs/synapse-rs"><img alt="docs.rs" src="https://img.shields.io/docsrs/synapse-rs"></a>
<a href="LICENSE"><img alt="License" src="https://img.shields.io/crates/l/synapse-rs"></a>
<a href="https://github.com/FlanZCode/synapse/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/FlanZCode/synapse/actions/workflows/ci.yml/badge.svg"></a>
</p>
**Synapse** scores real-world network quality from measurements you already have. It does not run speed tests — you collect the numbers; Synapse turns them into three metrics:
| **Vortex** | Performance / flow | down/up Mbps, ping, jitter, packet loss |
| **Radiance** | Wireless physical quality | RSSI, noise floor, channel width |
| **Axon** | Unified health | `√(Vortex × Radiance)`, or **Vortex alone on wired** links |
Scores are dimensionless. Use [`ScoreBand`](https://docs.rs/synapse-rs/latest/synapse_rs/enum.ScoreBand.html) for a coarse qualitative reading (critical → excellent).
## Installation
```toml
[dependencies]
synapse-rs = "1.1"
# Optional Serde support
# synapse-rs = { version = "1.1", features = ["serde"] }
```
## Example
```rust
use synapse_rs::{NetworkData, ScoreBand};
fn main() {
let data = NetworkData::new()
.with_down_mbps(150.0)
.with_up_mbps(40.0)
.with_ping_ms(18.0)
.with_jitter_ms(2.0)
.with_packet_loss_percent(0.0)
.with_rssi_dbm(-60.0)
.with_noise_dbm(-90.0)
.with_channel_width_mhz(40.0);
if let Some(axon) = data.calculate_axon() {
println!("Axon: {:.2} ({})", axon, ScoreBand::from_score(axon));
}
// Prefer try_* when you need structured errors:
match data.try_vortex() {
Ok(v) => println!("Vortex: {v:.2}"),
Err(e) => eprintln!("Vortex unavailable: {e}"),
}
}
```
### Wired (Ethernet) vs wireless
- **Wireless**: Axon is the geometric mean of Vortex and Radiance.
- **Wired** (no RSSI/noise/width): Axon falls back to Vortex so Ethernet still gets a health score.
- If wireless fields are present but **invalid** (e.g. RSSI below noise), Axon returns an error instead of silently treating the link as wired.
### Validation
`try_vortex` / `try_radiance` / `try_axon` reject non-finite values, negative speeds/latency/jitter, packet loss outside `0..=100`, zero channel width, and RSSI below the noise floor. The `calculate_*` helpers return `None` in those cases.
## Examples
```bash
cargo run --example axon
cargo run --example vortex
cargo run --example radiance
cargo run --example axon --features serde
```
## Contributing
1. Fork and clone `https://github.com/FlanZCode/synapse`
2. Create a branch: `git checkout -b my-feature`
3. Run `cargo test`, `cargo clippy -- -D warnings`, and `cargo fmt --check`
4. Open a pull request
## License
MIT — see [LICENSE](LICENSE).