Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Low-level synchronous IRTT client.

Client exposes the protocol steps directly: connect a UDP socket, open a session, send probes, receive replies, poll timeouts, and close. Callers that do not need to own this loop can use ManagedClient instead.

Implementations§

Source§

impl Client

Source

pub fn connect(config: ClientConfig) -> Result<Self, ClientError>

Resolve the configured server and create a connected UDP socket.

This validates local configuration and prepares the open request, but it does not contact the server. Call open to perform the IRTT open exchange.

Source

pub fn open(&mut self) -> Result<OpenOutcome, ClientError>

Perform the IRTT open exchange.

On success, returns the negotiated open outcome and transitions the client into either an open probe session or completed no-test state. Open attempts use ClientConfig::open_timeouts.

Source

pub fn close(&mut self) -> Result<Vec<ClientEvent>, ClientError>

Send a close request and emit a ClientEvent::SessionClosed event.

The close event means the client has sent its close packet and stopped tracking the session locally; it is not a server acknowledgement.

Source

pub fn next_send_deadline(&self) -> Option<Instant>

Return the monotonic deadline for the next probe send, if another probe is scheduled.

Source

pub fn probe_timeout(&self) -> Duration

Return the local timeout used to classify pending probes as lost.

Source

pub fn send_probe(&mut self) -> Result<Vec<ClientEvent>, ClientError>

Send one echo probe if the negotiated run is still active.

Returns an EchoSent event when a probe is sent. Returns an empty event list when the run duration has elapsed and no further probe should be sent.

Source

pub fn recv_once(&mut self) -> Result<Vec<ClientEvent>, ClientError>

Receive and classify at most one datagram from the socket.

Returns an empty event list when the socket read would block or times out. Malformed or unrelated datagrams are reported as warning events.

Source

pub fn recv_available( &mut self, budget: RecvBudget, ) -> Result<Vec<ClientEvent>, ClientError>

Receive and classify datagrams until a receive produces no events or the receive budget is exhausted.

Source

pub fn poll_timeouts(&mut self) -> Result<Vec<ClientEvent>, ClientError>

Polls for probes that have timed out as of the current monotonic time.

Source

pub fn poll_timeouts_at( &mut self, now: Instant, ) -> Result<Vec<ClientEvent>, ClientError>

Polls for probes that have timed out as of now.

This is useful for callers that drive Client from their own event loop and want timeout decisions to use the same sampled Instant as their scheduling logic.

now is monotonic time only; wall-clock time is not used for timeout expiry.

Source

pub fn is_run_complete(&self) -> bool

Return whether the current run has completed.

A normal run is complete once no more probes will be sent and all pending probes have either replied or timed out. No-test and closed sessions are also considered complete.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.