Struct connect::Connection [−][src]
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]
ip_addrs: A,
domain: &str,
connector: TlsConnector
) -> Result<Self>
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.
Connection
s 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
impl !RefUnwindSafe for Connection
[src]
impl Send for Connection
[src]
impl Sync for Connection
[src]
impl Unpin for Connection
[src]
impl !UnwindSafe for Connection
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,