pub async fn connect(
peer: &PeerTarget,
identity: &LocalIdentity,
config: &NatConfig,
) -> Result<PeerConnection, NatError>Expand description
Establish a mutually-authenticated connection to peer, choosing the traversal method
transparently (first success wins; relay is the last resort).
identity is this node’s mTLS identity (its client certificate + key); config selects which
methods are enabled + the per-method timeout + the relay/STUN endpoints. On success the returned
PeerConnection carries the verified remote peer_id, the TraversalKind that established
it, and the authenticated stream.
§Errors
NatError::NoMethodsEnabled— the config enabled no methods.NatError::AllMethodsFailed— every enabled method failed (with per-method reasons).NatError::InvalidConfig— the identity/relay/STUN config could not be used.
This function never panics and never hangs: every method (and its dial) is bounded by
NatConfig::per_method_timeout.