ProgressEvent

Enum ProgressEvent 

Source
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 start
  • interval_end - End time of this interval relative to test start
  • bytes - Number of bytes transferred during this interval
  • bits_per_second - Throughput in bits per second for this interval
  • packets - 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

§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

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 test
  • duration - Actual test duration
  • bits_per_second - Average throughput over the entire test
  • total_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

§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)

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

Source§

fn clone(&self) -> ProgressEvent

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgressEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V