Struct connect::ConnectionReader[][src]

pub struct ConnectionReader { /* fields omitted */ }

An interface to read messages from the network connection

Implements the [Stream] trait to asynchronously read messages from the network connection.

Example

Basic usage:

while let Some(msg) = reader.next().await {
  // handle the received message
}

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

Implementations

impl ConnectionReader[src]

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

Creates a new ConnectionReader from an [AsyncRead] 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 [Stream] of messages from the network is closed

Trait Implementations

impl Stream for ConnectionReader[src]

type Item = Any

Values yielded by the stream.

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<I> IntoStream for I where
    I: Stream, 
[src]

type Item = <I as Stream>::Item

The type of the elements being iterated over.

type IntoStream = I

Which kind of stream are we turning this into?

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<S> StreamExt for S where
    S: Stream + ?Sized

impl<T> StreamExt for T where
    T: Stream + ?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.