Struct QuicClientBuilder

Source
pub struct QuicClientBuilder<T> { /* private fields */ }
Expand description

A builder for QuicClient.

Implementations§

Source§

impl<T> QuicClientBuilder<T>

Source

pub fn with_iface_factory( self, factory: impl ProductQuicInterface + '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 UdpSocketController that support GSO and GRO, and the factory is UdpSocketController::bind.

Source

pub fn bind(self, addrs: impl ToSocketAddrs) -> Result<Self>

Create quic interfaces bound on given address.

If the bind failed, the error will be returned immediately.

The default quic interface is UdpSocketController that support GSO and GRO. You can let the client bind custom interfaces by calling the Self::with_iface_factory method.

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.

Source

pub fn reuse_connection(self) -> Self

Enable efficiently reuse connections.

If you enable this option the client will give priority to returning the existing connection to the server_name and server_addr, instead of creating a new connection every time.

Source

pub fn reuse_address(self) -> Self

Enable reuse interface.

If you dont bind any address, this option will not take effect.

By default, the client will not use the same interface with other connections, which means that the client must select a new interface every time it initiates a connection. If you enable this option, the client will share the same address between connections.

Source

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.

Source

pub fn defer_idle_timeout(self, config: HeartbeatConfig) -> 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.

Source

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.

transport parameters

Source

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.

transport parameters

Source

pub fn with_qlog(self, logger: Arc<dyn Log + Send + Sync>) -> Self

Source

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.

address verification

Source§

impl QuicClientBuilder<ConfigBuilder<ClientConfig, WantsVerifier>>

Source

pub fn with_root_certificates( self, root_store: impl Into<Arc<RootCertStore>>, ) -> QuicClientBuilder<ConfigBuilder<ClientConfig, WantsClientCert>>

Choose how to verify server certificates.

Read TlsClientConfigBuilder::with_root_certificates for more information.

Source

pub fn with_webpki_verifier( self, verifier: Arc<WebPkiServerVerifier>, ) -> QuicClientBuilder<ConfigBuilder<ClientConfig, WantsClientCert>>

Choose how to verify server certificates using a webpki verifier.

Read TlsClientConfigBuilder::with_webpki_verifier for more information.

Source

pub fn without_verifier( self, ) -> QuicClientBuilder<ConfigBuilder<ClientConfig, WantsClientCert>>

Dangerously disable server certificate verification.

Source§

impl QuicClientBuilder<ConfigBuilder<ClientConfig, WantsClientCert>>

Source

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.

Source

pub fn without_cert(self) -> QuicClientBuilder<TlsClientConfig>

Do not support client auth.

Source

pub fn with_cert_resolver( self, cert_resolver: Arc<dyn ResolvesClientCert>, ) -> QuicClientBuilder<TlsClientConfig>

Sets a custom ResolvesClientCert.

Source§

impl QuicClientBuilder<ClientConfig>

Source

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.

alpn-protocol-ids

Source

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.

Source

pub fn build(self) -> QuicClient

Build the QuicClient, ready to initiates connect to the servers.

Auto Trait Implementations§

§

impl<T> Freeze for QuicClientBuilder<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for QuicClientBuilder<T>

§

impl<T> Send for QuicClientBuilder<T>
where T: Send,

§

impl<T> Sync for QuicClientBuilder<T>
where T: Sync,

§

impl<T> Unpin for QuicClientBuilder<T>
where T: Unpin,

§

impl<T> !UnwindSafe for QuicClientBuilder<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more