Skip to main content

connect

Function connect 

Source
pub async fn connect<C, E, F, Fut>(
    local: &LocalStack,
    peer: &PeerCandidates,
    config: DialConfig,
    dial_fn: F,
) -> Result<DialWinner<C>, ConnectError<E>>
where E: Display + FromTimeout, F: Fn(SocketAddr) -> Fut + Sync, Fut: Future<Output = Result<C, E>> + Send, C: Send,
Expand description

Establish a connection to peer, IPv6-first with graceful IPv4 fallback, over the local∩peer family intersection (dial_order).

dial_fn performs one candidate’s transport connect (async, family-aware via the SocketAddr it is handed). On success the returned DialWinner reports the winning address + family; on failure ConnectError::NoCommonFamily (nothing dialable) or ConnectError::AllFailed (every candidate tried and failed).