pub struct WirePool { /* private fields */ }Expand description
WirePool - Wire connection pool manager
§Responsibilities
- Saturated concurrent connections (simultaneously attempt WebRTC + WebSocket)
- Automatic retry with exponential backoff
- Broadcast connection status (via watch channel, zero-polling)
- Keep all successful connections (no priority-based replacement)
§Design Highlights
- Event-driven: Use watch channels to notify status changes
- Zero-polling: Callers use
await ready_rx.changed()to wait for connection readiness - Array optimization: Use fixed-size array instead of HashMap
Implementations§
Source§impl WirePool
impl WirePool
Sourcepub fn add_connection(&self, connection: WireHandle)
pub fn add_connection(&self, connection: WireHandle)
Add connection and start connection task in background
Non-blocking, returns immediately and attempts connection concurrently in background
§Behavior
- Unconditionally starts: Always starts connection attempt, even if a connection already exists
- Use
add_connection_smart()if you want to skip already-ready connections
Sourcepub async fn add_connection_smart(&self, connection: WireHandle)
pub async fn add_connection_smart(&self, connection: WireHandle)
Add connection smartly - skip if already Ready or Connecting
§Behavior
- Ready: Skip (reuse existing connection)
- Connecting: Skip (avoid duplicate retry)
- None/Failed: Start connection attempt
§Use Case
Perfect for reconnection scenarios where you want to retry failed connections without disrupting working ones.
Sourcepub fn watch_ready(&self) -> Receiver<HashSet<ConnType>>
pub fn watch_ready(&self) -> Receiver<HashSet<ConnType>>
Watch for connection status changes
Sourcepub async fn get_connection(&self, conn_type: ConnType) -> Option<WireHandle>
pub async fn get_connection(&self, conn_type: ConnType) -> Option<WireHandle>
Get connection of specified type
Sourcepub async fn wait_for_any(&self) -> NetworkResult<()>
pub async fn wait_for_any(&self) -> NetworkResult<()>
Wait for any connection to become ready
Sourcepub async fn mark_connection_closed(&self, conn_type: ConnType)
pub async fn mark_connection_closed(&self, conn_type: ConnType)
Mark a connection as closed/failed
Called by upper layers (DestTransport) when closing connections. This replaces the per-connection event listener pattern.
Auto Trait Implementations§
impl Freeze for WirePool
impl !RefUnwindSafe for WirePool
impl Send for WirePool
impl Sync for WirePool
impl Unpin for WirePool
impl !UnwindSafe for WirePool
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more