Skip to main content

Reconnect

Struct Reconnect 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn closed(&self) -> Result<()>

Wait until the reconnect loop stops.

Trait Implementations§

Source§

impl Drop for Reconnect

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more