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
impl Client
Sourcepub fn connect(config: ClientConfig) -> Result<Self, ClientError>
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.
Sourcepub fn open(&mut self) -> Result<OpenOutcome, ClientError>
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.
Sourcepub fn close(&mut self) -> Result<Vec<ClientEvent>, ClientError>
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.
Sourcepub fn next_send_deadline(&self) -> Option<Instant>
pub fn next_send_deadline(&self) -> Option<Instant>
Return the monotonic deadline for the next probe send, if another probe is scheduled.
Sourcepub fn probe_timeout(&self) -> Duration
pub fn probe_timeout(&self) -> Duration
Return the local timeout used to classify pending probes as lost.
Sourcepub fn send_probe(&mut self) -> Result<Vec<ClientEvent>, ClientError>
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.
Sourcepub fn recv_once(&mut self) -> Result<Vec<ClientEvent>, ClientError>
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.
Sourcepub fn recv_available(
&mut self,
budget: RecvBudget,
) -> Result<Vec<ClientEvent>, ClientError>
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.
Sourcepub fn poll_timeouts(&mut self) -> Result<Vec<ClientEvent>, ClientError>
pub fn poll_timeouts(&mut self) -> Result<Vec<ClientEvent>, ClientError>
Polls for probes that have timed out as of the current monotonic time.
Sourcepub fn poll_timeouts_at(
&mut self,
now: Instant,
) -> Result<Vec<ClientEvent>, ClientError>
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.
Sourcepub fn is_run_complete(&self) -> bool
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.