Skip to main content

Module runtime

Module runtime 

Source
Expand description

The runtime-handle carrier — the LIVE transport handles + discovery inputs the data-only NatConfig deliberately cannot hold.

[NatConfig] is Clone + Debug DATA (which methods are enabled, timeouts, endpoints, the binding policy). The relay-dependent + port-mapping tiers additionally need LIVE, non-cloneable things — a relay coordinator, a relay data-plane, an IGD gateway handle, this node’s discovered addresses. Jam them into NatConfig and it could no longer be cheap cloneable data. So they live here, in a separate NatRuntime carrier that is intentionally neither Clone nor Debug (it holds Arc<dyn …> trait objects + live sockets). connect_with_runtime takes both — the config for the data, the runtime for the handles — and composes the FULL ladder.

Every field is OPTIONAL: a tier whose inputs are absent is simply NOT composed. This keeps the composition honest — connect never claims a tier it cannot actually run, and never produces a silently-broken dial. A node supplies exactly the handles it has (a NAT’d node with a relay reservation supplies the hole-punch + relayed handles; a node with a mappable gateway supplies the port + gateway; a fully-public node supplies none and gets Direct only).

Structs§

NatRuntime
Live transport handles + discovery inputs for the non-Direct traversal tiers. Built with a fluent builder; passed to connect_with_runtime alongside the NatConfig. Deliberately NOT Clone/Debug — it carries live Arc<dyn …> handles, unlike the data-only config.
NatRuntimeBuilder
Fluent builder for NatRuntime. Set only the handles this node actually has; the rest stay None and their tiers are not composed.