pub trait TransportInstaller:
Send
+ Sync
+ 'static {
// Required method
fn build(
&self,
profile: &TransportProfile,
) -> Result<TransportConfig, TransportProfileError>;
}Expand description
Builds the quinn::TransportConfig a leg installs.
A leg with a TransportProfile and no installer of its own uses
DefaultInstaller, so supplying one replaces exactly one step and
nothing else: the leg still installs whatever comes back, still installs
it before its endpoint exists, and still refuses a leg that names a raw
quinn::TransportConfig as well as a profile.
§What this is for: a base configuration and a profile
A leg takes a raw config or a profile, never both — see
ProxyError::TransportConfigAndProfile, which is where the reason is
written out. The short form is that
quinn::TransportConfig can be neither cloned nor read back, so no code
here can accept a caller’s config and return a modified copy of it.
An installer is how a caller has both anyway, and it works because it
builds the base rather than being handed one: build constructs its
own quinn::TransportConfig, applies the profile over it with
TransportProfile::apply_to, and returns the result. Nothing is
copied, so nothing is silently dropped, and the caller’s own settings
survive because the caller is the one making them.
Send + Sync + 'static because one installer serves every connection a
leg carries, for as long as the proxy runs, from whichever task accepts
them.
Required Methods§
Sourcefn build(
&self,
profile: &TransportProfile,
) -> Result<TransportConfig, TransportProfileError>
fn build( &self, profile: &TransportProfile, ) -> Result<TransportConfig, TransportProfileError>
Turn profile into the config this leg will install.
An error refuses the connection instead of falling back to a default. A leg that connected anyway would be running with parameters nobody chose while reporting success, which is the one outcome every rule in this module exists to prevent.
§Owned, not Arc
The return type is a plain quinn::TransportConfig and the reason is
what the caller may still need to do to it. A QUIC-level capture sink
is installed by mutating a quinn::TransportConfig, and an Arc
that may already be shared cannot be mutated — Arc::get_mut hands
back nothing the moment a second handle exists. An installer that
returned one would therefore be unusable on any leg that also asked
for a capture, and the only way to keep such a leg working would be
to skip the installer: a caller who supplied one would find it never
called, with nothing saying so. Handing back the value means the leg
can attach whatever else it owes to it and every setting survives.
The leg wraps the result in an Arc itself, once, after it has
finished with it. An implementation that has an Arc already should
build a fresh config rather than trying to unwrap one — that is the
same rebuild-per-leg this trait exists for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".