pub struct Reconnect { /* private fields */ }Expand description
Handle to a background reconnect loop.
Spawns a tokio task that connects, waits for session close, then reconnects with exponential
backoff. The read surface mirrors moq_net::Session so a caller can treat it like a session
that transparently reconnects: version, send_bandwidth,
and recv_bandwidth track the live session and reset while disconnected.
The extra toggle a plain session doesn’t have is the connection lifecycle: connected
reads it synchronously and status waits for the next change. closed
waits for the loop to stop. Dropping the handle aborts the background task.
Implementations§
Source§impl Reconnect
impl Reconnect
Sourcepub fn poll_status(&mut self, waiter: &Waiter) -> Poll<Result<Status>>
pub fn poll_status(&mut self, waiter: &Waiter) -> Poll<Result<Status>>
Poll for the next connection status change since this handle last reported one.
Ready(Ok(status)) on a change, Ready(Err) once the loop has stopped (the give-up error,
or a generic one when the handle is dropped), Pending otherwise.
Sourcepub async fn status(&mut self) -> Result<Status>
pub async fn status(&mut self) -> Result<Status>
Wait until the connection status changes from what this handle last reported.
Returns the current Status. The loop alternates Connected/Disconnected, so successive
calls alternate too; but a status that flips and flips back before the caller polls is
reported once. This tracks the current state, not every edge.
Sourcepub fn connected(&self) -> bool
pub fn connected(&self) -> bool
Whether a session is currently connected.
The synchronous read behind status, for callers that just want the current
state rather than the next change.
Sourcepub fn version(&self) -> Option<Version>
pub fn version(&self) -> Option<Version>
The negotiated MoQ version of the live session, or None while disconnected.
The moq_net::Session::version counterpart; Option because a reconnecting handle can be
between sessions.
Sourcepub fn send_bandwidth(&self) -> BandwidthConsumer
pub fn send_bandwidth(&self) -> BandwidthConsumer
A consumer for the live session’s estimated send bitrate, mirroring
moq_net::Session::send_bandwidth.
Unlike the session’s, this handle is persistent: the reconnect loop forwards each session’s
estimate into it, so it survives reconnects. Its value is None while disconnected or when the
backend has no estimate.
Sourcepub fn recv_bandwidth(&self) -> BandwidthConsumer
pub fn recv_bandwidth(&self) -> BandwidthConsumer
A consumer for the live session’s estimated receive bitrate, mirroring
moq_net::Session::recv_bandwidth. Persistent across reconnects like
send_bandwidth; None while disconnected or unavailable.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
Poll whether the reconnect loop has stopped.
Ready(Err) if it permanently gave up (reconnect timeout exceeded), Ready(Ok(())) if
stopped by dropping the handle, Pending while it’s still running.
Sourcepub fn stats(&self) -> ConnectionStatsReader
pub fn stats(&self) -> ConnectionStatsReader
A cloneable handle for reading the current connection’s stats.
The handle keeps working across reconnects, reporting None between connections.