Skip to main content

resolve

Function resolve 

Source
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 answer a leg that names no config, no profile and no installer must keep getting.

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 exactly as it was given; with no spec beside it, nothing here changes what the leg installs.
  • Raw config and a specProxyError::TransportConfigAndQlog, because the config arrives behind an Arc that can be neither cloned nor mutated. The variant carries the whole reason.
  • Profile and a spec — the leg’s TransportInstaller builds 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 because build hands back an owned quinn::TransportConfig rather than an Arc: 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 gets DefaultInstaller’s base, which is quinn::TransportConfig::default().
  • Spec alone — still a fresh quinn::TransportConfig with the sink on it, and the leg installs it. This is the case worth being careful about: 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.