diff --git a/crates/irtt-cli/Cargo.toml b/crates/irtt-cli/Cargo.toml index 17695d7..363dff3 100644 --- a/crates/irtt-cli/Cargo.toml +++ b/crates/irtt-cli/Cargo.toml @@ -11,6 +11,9 @@ readme.workspace = true keywords = ["irtt", "networking", "latency", "rtt"] categories = ["command-line-utilities", "network-programming"] +[lib] +doc = false + [features] default = ["stats"] stats = ["dep:irtt-stats"] diff --git a/crates/irtt-client/src/lib.rs b/crates/irtt-client/src/lib.rs index d42657a..fc6d960 100644 --- a/crates/irtt-client/src/lib.rs +++ b/crates/irtt-client/src/lib.rs @@ -1,3 +1,50 @@ +//! Reusable client/session/event layer for IRTT-compatible probes. +//! +//! `irtt-client` opens IRTT-compatible sessions, sends echo probes, receives +//! replies, classifies loss/late/duplicate packets, and emits [`ClientEvent`] +//! values for callers to consume directly or aggregate with `irtt-stats`. +//! +//! Timing values intentionally preserve signed measurement semantics. When +//! server timing is available, [`RttSample::effective`] is adjusted for server +//! processing and can be negative if the reported server processing time exceeds +//! the raw client-observed RTT. Directional [`OneWayDelaySample`] values are +//! also signed when the required wall-clock timestamps are available; negative +//! values usually indicate client/server clock skew. +//! +//! A managed session can drive the socket loop on a worker thread and publish +//! events through a subscription: +//! +//! ```no_run +//! use std::time::Duration; +//! +//! use irtt_client::{ClientConfig, ClientEvent, ManagedClient, SubscriberConfig}; +//! +//! # fn main() -> Result<(), Box> { +//! let config = ClientConfig { +//! server_addr: "127.0.0.1:2112".to_owned(), +//! duration: Some(Duration::from_secs(10)), +//! interval: Duration::from_secs(1), +//! ..ClientConfig::default() +//! }; +//! +//! let (session, events) = +//! ManagedClient::start_with_subscription(config, SubscriberConfig::default())?; +//! +//! while let Ok(event) = events.recv() { +//! match event { +//! ClientEvent::EchoReply { seq, rtt, .. } => { +//! println!("seq={seq} effective_rtt_us={}", rtt.effective.as_micros()); +//! } +//! ClientEvent::SessionClosed { .. } => break, +//! _ => {} +//! } +//! } +//! +//! let _outcome = session.join()?; +//! # Ok(()) +//! # } +//! ``` +//! #![cfg_attr( not(all(target_os = "linux", feature = "ancillary")), forbid(unsafe_code) diff --git a/crates/irtt-proto/src/lib.rs b/crates/irtt-proto/src/lib.rs index 06a352b..e185347 100644 --- a/crates/irtt-proto/src/lib.rs +++ b/crates/irtt-proto/src/lib.rs @@ -1,3 +1,21 @@ +//! Low-level wire encode/decode support for the IRTT protocol. +//! +//! `irtt-proto` intentionally mirrors protocol fields closely: request/reply +//! structs expose wire-oriented values, flags, counters, timestamps, and +//! parameter enums rather than higher-level policy decisions. Higher-level +//! crates such as `irtt-client` are responsible for session behavior and +//! user-facing validation. +//! +//! [`Params::decode`] rejects malformed or incompatible incoming parameter +//! values, including invalid enum discriminants, malformed UTF-8, and oversized +//! `server_fill` values. Direct construction followed by [`Params::encode`] +//! performs no additional validation, so callers that build `Params` manually +//! are responsible for validating those values before sending them. +//! +//! The crate also provides packet layout calculation, open/echo/close packet +//! encoding and decoding, and optional HMAC placement, computation, and +//! verification helpers. +//! #![forbid(unsafe_code)] pub mod close;