Struct s2n_quic::client::Client

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

A QUIC client endpoint, capable of opening connections

Implementations§

source§

impl Client

source

pub fn bind<T>(socket: T) -> Result<Self, StartError>
where T: TryInto,

Starts listening on the provided socket

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

pub fn builder() -> Builder<impl ClientProviders>

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()?;
source

pub fn connect(&self, connect: Connect) -> ConnectionAttempt

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?;
source

pub async fn wait_idle(&mut self) -> Result<(), Error>

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?;
source

pub fn local_addr(&self) -> Result<SocketAddr, Error>

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§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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, 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

source§

fn upcast(self) -> T

source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

source§

fn upcast_from(value: Counter<T, B>) -> T

source§

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

source§

fn vzip(self) -> V