Struct connect::ConnectionWriter[][src]

pub struct ConnectionWriter { /* fields omitted */ }

An interface to write messages to the network connection

Implements the [Sink] trait to asynchronously write messages to the network connection.

Example

Basic usage:

writer.send(msg).await?;

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

Implementations

impl ConnectionWriter[src]

pub fn new(
    local_addr: SocketAddr,
    peer_addr: SocketAddr,
    write_stream: Pin<Box<dyn AsyncWrite + Send + Sync>>
) -> Self
[src]

Creates a new ConnectionWriter from an [AsyncWrite] trait object and the local and peer socket metadata

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 is_closed(&self) -> bool[src]

Check if the [Sink] of messages to the network is closed

Trait Implementations

impl<M: Message> Sink<M> for ConnectionWriter[src]

type Error = RecvError

The type of value produced by the sink when an error occurs.

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, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized

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.