pub struct QuicClientBuilder<T> { /* private fields */ }
Expand description
A builder for QuicClient
.
Implementations§
Source§impl<T> QuicClientBuilder<T>
impl<T> QuicClientBuilder<T>
Sourcepub fn with_iface_factory(self, factory: impl ProductQuicIO + 'static) -> Self
pub fn with_iface_factory(self, factory: impl ProductQuicIO + 'static) -> Self
Specify how client bind interfaces.
The given factory will be used by Self::bind
,
and/or QuicClient::connect
if no interface bound when client built.
The default quic interface is provided by handy::DEFAULT_QUIC_IO_FACTORY
.
For Unix and Windows targets, this is a high performance UDP library supporting GSO and GRO
provided by qudp
crate. For other platforms, please specify you own factory.
Sourcepub fn bind(self, addrs: impl IntoIterator<Item = impl Into<BindUri>>) -> Self
pub fn bind(self, addrs: impl IntoIterator<Item = impl Into<BindUri>>) -> Self
Create quic interfaces bound on given address.
If the bind failed, the error will be returned immediately.
The default quic interface is provided by handy::DEFAULT_QUIC_IO_FACTORY
.
For Unix and Windows targets, this is a high performance UDP library supporting GSO and GRO
provided by qudp
crate. For other platforms, please specify you own factory with
QuicClientBuilder::with_iface_factory
.
If you dont bind any address, each time the client initiates a new connection, the client will use bind a new interface on address and port that dynamic assigned by the system.
To know more about how the client selects the interface when initiates a new connection,
read QuicClient::connect
.
If you call this multiple times, only the last set of interface will be used, previous bound interface will be freed immediately.
If the interface is closed for some reason after being created (meaning QuicInterface::poll_recv
returns an error), only the log will be printed.
If all interfaces are closed, clients will no longer be able to initiate new connections.
Sourcepub fn prefer_versions(self, versions: impl IntoIterator<Item = u32>) -> Self
pub fn prefer_versions(self, versions: impl IntoIterator<Item = u32>) -> Self
(WIP)Specify the quic versions that the client prefers.
If you call this multiple times, only the last call will take effect.
Sourcepub fn defer_idle_timeout(self, duration: Duration) -> Self
pub fn defer_idle_timeout(self, duration: Duration) -> Self
Provide an option to defer an idle timeout.
This facility could be used when the application wishes to avoid losing state that has been associated with an open connection but does not expect to exchange application data for some time.
See Deferring Idle Timeout of RFC 9000 for more information.
Sourcepub fn with_parameters(self, parameters: ClientParameters) -> Self
pub fn with_parameters(self, parameters: ClientParameters) -> Self
Specify the [transport parameters] for the client.
If you call this multiple times, only the last parameters
will be used.
Usually, you don’t need to call this method, because the client will use a set of default parameters.
Sourcepub fn with_streams_concurrency_strategy(
self,
strategy_factory: impl ProductStreamsConcurrencyController + 'static,
) -> Self
pub fn with_streams_concurrency_strategy( self, strategy_factory: impl ProductStreamsConcurrencyController + 'static, ) -> Self
Specify the streams concurrency strategy controller for the client.
The streams controller is used to control the concurrency of data streams. controller
is a closure that accept
(initial maximum number of bidirectional streams, initial maximum number of unidirectional streams) configured in
[transport parameters] and return a ControlConcurrency
object.
If you call this multiple times, only the last controller
will be used.
Sourcepub fn with_qlog(self, logger: Arc<dyn Log + Send + Sync>) -> Self
pub fn with_qlog(self, logger: Arc<dyn Log + Send + Sync>) -> Self
Specify qlog collector for server connections.
If you call this multiple times, only the last logger
will be used.
Pre-implemented loggers:
-
LegacySeqLogger
: Generates qlog files compatible with qvis visualization.LegacySeqLogger::new(PathBuf::from("/dir"))
: Write to files{connection_id}_{role}.sqlog
indir
LegacySeqLogger::new(tokio::io::stdout())
: Stream to stdoutLegacySeqLogger::new(tokio::io::stderr())
: Stream to stderr
Output format: JSON-SEQ (RFC7464), one JSON event per line.
-
NoopLogger
: Ignores all qlog events (default, recommended for production).
Sourcepub fn with_token_sink(self, sink: Arc<dyn TokenSink>) -> Self
pub fn with_token_sink(self, sink: Arc<dyn TokenSink>) -> Self
Specify the token sink for the client.
The token sink is used to storage the tokens that the client received from the server. The client will use the tokens to prove it self to the server when it reconnects to the server. read [address verification] in quic rfc for more information.
Source§impl QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsVerifier>>
impl QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsVerifier>>
Sourcepub fn with_root_certificates(
self,
root_store: impl Into<Arc<RootCertStore>>,
) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
pub fn with_root_certificates( self, root_store: impl Into<Arc<RootCertStore>>, ) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
Choose how to verify server certificates.
Read TlsClientConfigBuilder::with_root_certificates for more information.
Sourcepub fn with_webpki_verifier(
self,
verifier: Arc<WebPkiServerVerifier>,
) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
pub fn with_webpki_verifier( self, verifier: Arc<WebPkiServerVerifier>, ) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
Choose how to verify server certificates using a webpki verifier.
Read TlsClientConfigBuilder::with_webpki_verifier for more information.
Sourcepub fn without_verifier(
self,
) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
pub fn without_verifier( self, ) -> QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
Dangerously disable server certificate verification.
Source§impl QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
impl QuicClientBuilder<ConfigBuilder<TlsClientConfig, WantsClientCert>>
Sourcepub fn with_cert(
self,
cert_chain: impl ToCertificate,
key_der: impl ToPrivateKey,
) -> QuicClientBuilder<TlsClientConfig>
pub fn with_cert( self, cert_chain: impl ToCertificate, key_der: impl ToPrivateKey, ) -> QuicClientBuilder<TlsClientConfig>
Sets a single certificate chain and matching private key for use in client authentication.
Read TlsClientConfigBuilder::with_single_cert for more information.
Sourcepub fn without_cert(self) -> QuicClientBuilder<TlsClientConfig>
pub fn without_cert(self) -> QuicClientBuilder<TlsClientConfig>
Do not support client auth.
Sourcepub fn with_cert_resolver(
self,
cert_resolver: Arc<dyn ResolvesClientCert>,
) -> QuicClientBuilder<TlsClientConfig>
pub fn with_cert_resolver( self, cert_resolver: Arc<dyn ResolvesClientCert>, ) -> QuicClientBuilder<TlsClientConfig>
Sets a custom ResolvesClientCert
.
Source§impl QuicClientBuilder<TlsClientConfig>
impl QuicClientBuilder<TlsClientConfig>
Sourcepub fn with_alpns(
self,
alpns: impl IntoIterator<Item = impl Into<Vec<u8>>>,
) -> Self
pub fn with_alpns( self, alpns: impl IntoIterator<Item = impl Into<Vec<u8>>>, ) -> Self
Specify the [alpn-protocol-ids] that will be sent in ClientHello
.
By default, its empty and the APLN extension wont be sent.
If you call this multiple times, all the alpn_protocol
will be used.
Sourcepub fn enable_sslkeylog(self) -> Self
pub fn enable_sslkeylog(self) -> Self
Enable the keylog
feature.
This is useful when you want to debug the TLS connection.
The keylog file will be in the file that environment veriable SSLKEYLOGFILE
pointed to.
Read rustls::KeyLogFile
for more information.
pub fn enable_0rtt(self) -> Self
Sourcepub fn build(self) -> QuicClient
pub fn build(self) -> QuicClient
Build the QuicClient, ready to initiates connect to the servers.