pub trait Connector:
Send
+ Sync
+ 'static {
type Transport: Transport;
type Runtime: RuntimeTrait;
type Udp: UdpTransport;
// Required methods
fn connect(
&self,
url: &Url,
) -> impl Future<Output = Result<Self::Transport, Error>> + Send;
fn resolve(
&self,
host: &str,
port: u16,
) -> impl Future<Output = Result<Vec<SocketAddr>, Error>> + Send;
fn runtime(&self) -> Self::Runtime;
// Provided methods
fn connect_to(
&self,
destination: Destination,
) -> impl Future<Output = Result<Self::Transport, Error>> + Send { ... }
fn connect_over(
&self,
transport: Box<dyn Transport>,
destination: Destination,
) -> impl Future<Output = Result<Box<dyn Transport>, Error>> + Send { ... }
fn arced(self) -> ArcedConnector
where Self: Sized { ... }
}Expand description
Interface for runtime and tls adapters for the trillium client
See
trillium_client for more
information on usage.
Required Associated Types§
Sourcetype Runtime: RuntimeTrait
type Runtime: RuntimeTrait
The RuntimeTrait for this Connector
Sourcetype Udp: UdpTransport
type Udp: UdpTransport
The async UDP socket type for this connector. Used by QUIC adapters
for HTTP/3 support. Connectors that do not support UDP should set
this to ().
Required Methods§
Sourcefn connect(
&self,
url: &Url,
) -> impl Future<Output = Result<Self::Transport, Error>> + Send
fn connect( &self, url: &Url, ) -> impl Future<Output = Result<Self::Transport, Error>> + Send
Initiate a connection to the provided url
Provided Methods§
Sourcefn connect_to(
&self,
destination: Destination,
) -> impl Future<Output = Result<Self::Transport, Error>> + Send
fn connect_to( &self, destination: Destination, ) -> impl Future<Output = Result<Self::Transport, Error>> + Send
Open a connection to destination: dialing its pre-resolved addresses if present, otherwise
resolving its host, and advertising any per-connection ALPN it carries.
A domain destination keeps its host as the certificate identity (SNI) regardless of the addresses dialed, so pre-resolved addresses may come from any resolver (e.g. a DNS cache) without affecting certificate validation.
The default implementation reconstructs a URL via Destination::to_url and calls
connect, which ignores pre-resolved addresses and per-connection
ALPN; connectors that honor those override this method.
destination is taken by value so connectors can adjust it (e.g. clearing secure before
delegating the TCP dial to an inner connector) without copying. A caller that needs to
retain it should clone before calling.
Sourcefn connect_over(
&self,
transport: Box<dyn Transport>,
destination: Destination,
) -> impl Future<Output = Result<Box<dyn Transport>, Error>> + Send
fn connect_over( &self, transport: Box<dyn Transport>, destination: Destination, ) -> impl Future<Output = Result<Box<dyn Transport>, Error>> + Send
Establish this connector’s transport security for destination over an already-open
byte stream — e.g. an HTTP CONNECT tunnel — instead of dialing.
destination describes the far end of transport. When destination.secure() is true, a
TLS connector handshakes over transport: SNI and certificate validation use the
destination’s host, or for a host-less destination the first of destination.addrs() —
never transport’s peer address, which belongs to whatever the stream was opened to (e.g.
the proxy). The per-connection ALPN override applies as in
connect_to. Nothing is dialed; pre-resolved addresses serve only
as the bare-IP identity.
§Errors
The default returns transport unchanged for a non-secure destination and
io::ErrorKind::Unsupported for a secure one, so a connector that can’t layer TLS never
silently downgrades.
Sourcefn arced(self) -> ArcedConnectorwhere
Self: Sized,
fn arced(self) -> ArcedConnectorwhere
Self: Sized,
Returns an object-safe ArcedConnector. Do not implement this.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".