pub(crate) fn resolve(
leg: Leg,
raw: Option<Arc<TransportConfig>>,
profile: Option<&TransportProfile>,
installer: Option<&Arc<dyn TransportInstaller>>,
) -> Result<Option<Arc<TransportConfig>>, ProxyError>Expand description
What a leg installs, from the fields a caller may have set and the installer it may have supplied.
None back means the leg installs nothing and quinn’s defaults apply,
which is the case that has to stay bit-identical to the behaviour from
before profiles existed.
Called once per leg, before the endpoint is built, so every refusal below costs a caller no socket, no handshake and no connection to tear down — and none of them can be mistaken for a network fault, which is what the same error arriving mid-connection would look like.
An installer with no profile beside it is not consulted: build takes a
profile and there is none to give it. That is the one inert combination
here, and it is called out on both installer fields rather than left
for a caller to discover from a run where nothing happened.
§A spec changes what three of those cases install
Under the qlog feature a leg may also carry a qlog::QlogSpec — named
in plain code font here, as the variants below are, because none of it
exists in a build without the feature and a link from this
always-compiled item would not resolve. A sink can only be installed by
mutating a quinn::TransportConfig this function still holds by value,
and that single fact decides all four combinations:
- Raw config alone — installed as it was given, exactly as before.
- Raw config and a spec —
ProxyError::TransportConfigAndQlog, because the config arrives behind anArcthat can be neither cloned nor mutated. The variant carries the whole reason. - Profile and a spec — the leg’s
TransportInstallerbuilds the config, exactly as it does for a profile with no spec beside it, and the sink is attached to what it returned. The three compose becausebuildhands back an ownedquinn::TransportConfigrather than anArc: the base is the caller’s, the profile is applied over it by the installer, and the sink goes on last. A leg with no installer of its own getsDefaultInstaller’s base, which isquinn::TransportConfig::default(). - Spec alone — still a fresh
quinn::TransportConfigwith the sink on it, and the leg installs it. This is the case worth being careful about: a leg that named only a spec used to install nothing, and installing nothing here would leave the commonest way of asking for a capture producing no capture and no error.
A spec with no writer never reaches an endpoint: attach_to validates
before it builds, so QlogError::NoWriter is answered here, and by the
time a connection exists the sink is one quinn actually returned rather
than the silent None it answers a writer-less configuration with.