pub struct Client { /* private fields */ }
Expand description

A QUIC client endpoint, capable of opening connections

Implementations

Starts listening on the provided socket

Examples
let Client = Client::bind("0.0.0.0:0")?;

Returns a Builder which is able to configure the Client components.

Examples
use std::path::Path;
use s2n_quic::Client;

let client = Client::builder()
    .with_tls(Path::new("./certs/cert.pem"))?
    .with_io("0.0.0.0:0")?
    .start()?;

Establishes a connection to the specified endpoint

Examples
use s2n_quic::Client;
use std::{net::SocketAddr, path::Path};

let client = Client::builder()
    .with_tls(Path::new("./certs/cert.pem"))?
    .with_io("0.0.0.0:0")?
    .start()?;

let addr: SocketAddr = "127.0.0.1:443".parse()?;
let connection = client.connect(addr.into()).await?;

Wait for the client endpoint to finish handling all outstanding connections

Notifies the endpoint of application interest in closing the endpoint. The call waits for all outstanding connections to finish before returning.

Note: The endpoint will continue to accept new connection attempts. If there are other client handles with active connections, then this call will never return.

Examples
use s2n_quic::Client;
use std::{net::SocketAddr, path::Path};

let mut client = Client::builder()
    .with_tls(Path::new("./certs/cert.pem"))?
    .with_io("0.0.0.0:0")?
    .start()?;

let addr: SocketAddr = "127.0.0.1:443".parse()?;
let connection = client.connect(addr.into()).await?;

client.wait_idle().await?;

Returns the local address that this listener is bound to.

This can be useful, for example, when binding to port 0 to figure out which port was actually bound.

Examples
let client = Client::bind("0.0.0.0:0")?;

let local_addr = client.local_addr()?;
assert_ne!(local_addr.port(), 0);

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.