[][src]Struct simple_message_channels::Reader

pub struct Reader<R> { /* fields omitted */ }

A reader for SMC messages.

Takes any futures::io::AsyncRead and is a async_std::stream::Stream of Messages.

Example

use simple_message_channels::Reader;
let stdin = io::stdin().lock().await;
let mut reader = Reader::new(stdin);
while let Some(msg) = reader.next().await {
    let msg = msg?;
    println!("Received: ch {} typ {} msg {:?}", msg.channel, msg.typ, text);
}

Methods

impl<R> Reader<R> where
    R: AsyncRead + Send + Unpin + 'static, 
[src]

pub fn new(reader: R) -> Self[src]

Create a new message reader from any async_std::io::Read.

Trait Implementations

impl<R> Stream for Reader<R> where
    R: AsyncRead + Send + Unpin + 'static, 
[src]

type Item = Result<Message, Error>

Values yielded by the stream.

Auto Trait Implementations

impl<R> !Send for Reader<R>

impl<R> !Sync for Reader<R>

impl<R> Unpin for Reader<R>

impl<R> !UnwindSafe for Reader<R>

impl<R> !RefUnwindSafe for Reader<R>

Blanket Implementations

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 = !

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.

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

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

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

impl<T> StreamExt for T where
    T: Stream + ?Sized
[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<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

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

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]