pub struct Client { /* private fields */ }
Expand description
A QUIC client endpoint, capable of opening connections
Implementations
sourceimpl Client
impl Client
sourcepub fn bind<T>(socket: T) -> Result<Self, StartError>where
T: TryInto,
pub fn bind<T>(socket: T) -> Result<Self, StartError>where
T: TryInto,
sourcepub fn builder() -> Builder<impl ClientProviders>
pub fn builder() -> Builder<impl ClientProviders>
sourcepub fn connect(&self, connect: Connect) -> ConnectionAttemptⓘNotable traits for ConnectionAttemptimpl Future for ConnectionAttempt type Output = Result<Connection, Error>;
pub fn connect(&self, connect: Connect) -> ConnectionAttemptⓘNotable traits for ConnectionAttemptimpl Future for ConnectionAttempt type Output = Result<Connection, Error>;
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?;
sourcepub async fn wait_idle(&mut self) -> Result<(), Error>
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?;
sourcepub fn local_addr(&self) -> Result<SocketAddr, Error>
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
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more