Skip to main content

netspeed_cli/
lib.rs

1//! # netspeed-cli
2//!
3//! A command-line internet bandwidth tester using speedtest.net servers.
4//!
5//! ## Overview
6//!
7//! This crate provides both a library and a binary (`netspeed-cli`) for
8//! measuring download speed, upload speed, latency, jitter, and latency
9//! under load. It connects to speedtest.net's server infrastructure to
10//! perform real-world bandwidth tests.
11//!
12//! ## Key Features
13//!
14//! - **Multi-format output**: dashboard, detailed, compact, simple, minimal, JSON, JSONL, CSV
15//! - **Theming**: dark, light, high-contrast, monochrome with `NO_COLOR` support
16//! - **User profiles**: gamer, streamer, remote-worker, power-user, casual
17//! - **Quality grading**: A–F ratings for each metric and an overall score
18//! - **Latency under load**: measures ping degradation during bandwidth saturation
19//! - **Test history**: persistent local storage with backup and corruption recovery
20//! - **TLS options**: custom CA certs, domain-restricted TLS, configurable TLS version
21//!
22//! ## Modules
23//!
24//! - [`bandwidth_loop`] — Inner bandwidth measurement loop with live progress
25//! - [`bin_errors`] — Binary-level error handling and exit codes
26//! - [`cli`] — Command-line argument parsing with clap
27//! - [`common`] — Shared utilities (bandwidth calculation, formatting, validation)
28//! - [`config`] — Configuration management (CLI args + config file)
29//! - [`domain`] — Core business logic (measurement, reporting, server, speedtest)
30//! - [`download`] — Multi-stream download bandwidth measurement
31//! - [`endpoints`] — Canonical speedtest endpoint derivation
32//! - [`error`] — Unified error types with categorization
33//! - [`formatter`] — Output formatting (dashboard, detailed, compact, simple, JSON, CSV)
34//! - [`grades`] — Quality grade system (A–F ratings)
35//! - [`history`] — Persistent test result history with sparkline trends
36//! - [`http`] — HTTP client creation and IP discovery
37//! - [`http_client`] — Typed HTTP client abstraction
38//! - [`logging`] — Structured JSON logging
39//! - [`orchestrator`] — Top-level test orchestration and service wiring
40//! - [`output`] — Output dispatch and rendering
41//! - [`output_strategy`] — Format resolution from config and flags
42//! - [`phase_registry`] — Phase registration and lookup
43//! - [`phase_runner`] — Phase execution with template method pattern
44//! - [`phases`] — Phase context and executor definitions
45//! - [`profiles`] — User profiles/roles (gamer, streamer, etc.)
46//! - [`progress`] — Terminal progress bars, spinners, and sparklines
47//! - [`result_processor`] — Result aggregation and processing
48//! - [`servers`] — Server discovery, distance calculation, and selection
49//! - [`services`] — Service container for dependency injection
50//! - [`storage`] — Abstract storage trait for test results
51//! - [`task_runner`] — Test orchestration with retry and timeout
52//! - [`terminal`] — Terminal capability detection (color, animation, width)
53//! - [`test_config`] — Per-test configuration (retries, stream count)
54//! - [`theme`] — Color theming (Dark, Light, HighContrast, Monochrome)
55//! - [`types`] — Shared data structures (Server, TestResult, etc.)
56//! - [`upload`] — Multi-stream upload bandwidth measurement
57
58// Pedantic lints allowed at crate level — too noisy for a CLI bandwidth tester.
59// Individual modules may re-enable specific lints where stricter checking is desired.
60#![allow(
61    clippy::cast_precision_loss,
62    clippy::cast_possible_truncation,
63    clippy::cast_sign_loss
64)]
65
66pub mod bandwidth_loop;
67pub mod bin_errors;
68pub mod cli;
69pub mod common;
70pub mod config;
71pub mod domain;
72pub mod download;
73pub mod endpoints;
74pub mod error;
75pub mod formatter;
76pub mod grades;
77pub mod history;
78pub mod http;
79pub mod http_client;
80pub mod logging;
81pub mod orchestrator;
82pub mod output;
83pub mod output_strategy;
84pub mod phase_registry;
85pub mod phase_runner;
86pub mod phases;
87pub mod profiles;
88pub mod progress;
89pub mod result_processor;
90pub mod servers;
91pub mod services;
92pub mod storage;
93pub mod task_runner;
94pub mod terminal;
95pub mod test_config;
96pub mod theme;
97pub mod types;
98pub mod upload;