Struct connect::Connection[][src]

pub struct Connection { /* fields omitted */ }

Wrapper around a ConnectionReader and ConnectionWriter to read and write on a network connection.

Implementations

impl Connection[src]

pub async fn tcp_client<A: ToSocketAddrs + Display>(ip_addrs: A) -> Result<Self>[src]

Creates a Connection that uses a TCP transport.

Example

Please see the tcp-client example program for a more thorough showcase.

Basic usage:

let mut conn = Connection::tcp_client("127.0.0.1:3456").await?;

impl Connection[src]

pub async fn tls_client<A: ToSocketAddrs + Display>(
    ip_addrs: A,
    domain: &str,
    connector: TlsConnector
) -> Result<Self>
[src]

Creates a Connection that uses a TLS transport.

Example

Please see the tls-client example program for a more thorough showcase.

Basic usage:

let mut conn = Connection::tls_client("127.0.0.1:3456", "localhost", client_config.into()).await?;

impl Connection[src]

pub fn local_addr(&self) -> SocketAddr[src]

Get the local IP address and port.

pub fn peer_addr(&self) -> SocketAddr[src]

Get the peer IP address and port.

pub fn split(self) -> (ConnectionReader, ConnectionWriter)[src]

Consume the Connection to split into separate ConnectionReader and ConnectionWriter halves.

Connections are split when reading and writing must be concurrent operations.

pub fn join(reader: ConnectionReader, writer: ConnectionWriter) -> Self[src]

Re-wrap the ConnectionReader and ConnectionWriter halves into a Connection.

pub fn reader(&mut self) -> &mut ConnectionReader[src]

Get mutable access to the underlying ConnectionReader.

pub fn writer(&mut self) -> &mut ConnectionWriter[src]

Get mutable access to the underlying ConnectionWriter.

pub async fn close(self) -> SocketAddr[src]

Close the connection by closing both the reading and writing halves.

Trait Implementations

impl From<TcpStream> for Connection[src]

fn from(stream: TcpStream) -> Self[src]

Creates a Connection using a TCP transport from an async TcpStream.

impl From<TlsConnectionMetadata> for Connection[src]

fn from(metadata: TlsConnectionMetadata) -> Self[src]

Creates a Connection using a TLS transport from TlsConnectionMetadata.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.