pub enum ProgressEvent {
TestStarted,
IntervalUpdate {
interval_start: Duration,
interval_end: Duration,
bytes: u64,
bits_per_second: f64,
packets: Option<u64>,
jitter_ms: Option<f64>,
lost_packets: Option<u64>,
lost_percent: Option<f64>,
retransmits: Option<u64>,
},
TestCompleted {
total_bytes: u64,
duration: Duration,
bits_per_second: f64,
total_packets: Option<u64>,
jitter_ms: Option<f64>,
lost_packets: Option<u64>,
lost_percent: Option<f64>,
out_of_order: Option<u64>,
},
Error(String),
}Expand description
Progress event types reported during test execution.
These events allow monitoring of test progress in real-time through callbacks. Events are emitted for test lifecycle stages and periodic updates.
§Examples
use rperf3::{Client, Config, ProgressEvent};
use std::time::Duration;
let config = Config::client("127.0.0.1".to_string(), 5201)
.with_duration(Duration::from_secs(10));
let client = Client::new(config)?
.with_callback(|event: ProgressEvent| {
match event {
ProgressEvent::TestStarted => println!("Starting..."),
ProgressEvent::IntervalUpdate { bits_per_second, .. } => {
println!("Speed: {:.2} Mbps", bits_per_second / 1_000_000.0);
}
ProgressEvent::TestCompleted { total_bytes, .. } => {
println!("Transferred {} bytes", total_bytes);
}
ProgressEvent::Error(msg) => eprintln!("Error: {}", msg),
}
});
client.run().await?;Variants§
TestStarted
Test is starting.
This event is emitted once at the beginning of test execution.
IntervalUpdate
Interval update with statistics.
Emitted periodically (based on the interval configuration) with cumulative statistics for the current interval.
§Fields
interval_start- Start time of this interval relative to test startinterval_end- End time of this interval relative to test startbytes- Number of bytes transferred during this intervalbits_per_second- Throughput in bits per second for this intervalpackets- Number of packets (UDP only)jitter_ms- Jitter in milliseconds (UDP only)lost_packets- Number of lost packets (UDP only)lost_percent- Packet loss percentage (UDP only)retransmits- Number of TCP retransmits (TCP only)
Fields
TestCompleted
Test completed with final measurements.
Emitted once at the end of a successful test with total statistics.
§Fields
total_bytes- Total bytes transferred during the entire testduration- Actual test durationbits_per_second- Average throughput over the entire testtotal_packets- Total packets sent/received (UDP only)jitter_ms- Final jitter measurement in milliseconds (UDP only)lost_packets- Total lost packets (UDP only)lost_percent- Final packet loss percentage (UDP only)out_of_order- Out-of-order packet count (UDP only)
Fields
Error(String)
Error occurred during test execution.
Contains a descriptive error message. After this event, the test will typically terminate.
Trait Implementations§
Source§impl Clone for ProgressEvent
impl Clone for ProgressEvent
Source§fn clone(&self) -> ProgressEvent
fn clone(&self) -> ProgressEvent
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ProgressEvent
impl RefUnwindSafe for ProgressEvent
impl Send for ProgressEvent
impl Sync for ProgressEvent
impl Unpin for ProgressEvent
impl UnwindSafe for ProgressEvent
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)