[][src]Trait async_std::stream::FromStream

pub trait FromStream<T> {
    fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
        stream: S
    ) -> Pin<Box<dyn Future<Output = Self> + 'a>>; }
This is supported on unstable only.

Conversion from a Stream.

By implementing FromStream for a type, you define how it will be created from a stream. This is common for types which describe a collection of some kind.

See also: IntoStream.

Required methods

Important traits for Pin<P>
fn from_stream<'a, S: IntoStream<Item = T> + 'a>(
    stream: S
) -> Pin<Box<dyn Future<Output = Self> + 'a>>

This is supported on unstable only.

Creates a value from a stream.

Examples

Basic usage:

// use async_std::stream::FromStream;

// let _five_fives = async_std::stream::repeat(5).take(5);
Loading content...

Implementations on Foreign Types

impl<T> FromStream<T> for Vec<T>[src]

impl<T, E, V> FromStream<Result<T, E>> for Result<V, E> where
    V: FromStream<T>, 
[src]

Important traits for Pin<P>
fn from_stream<'a, S: IntoStream<Item = Result<T, E>>>(
    stream: S
) -> Pin<Box<dyn Future<Output = Self> + 'a>> where
    <S as IntoStream>::IntoStream: 'a, 
[src]

This is supported on unstable only.

Takes each element in the stream: if it is an Err, no further elements are taken, and the Err is returned. Should no Err occur, a container with the values of each Result is returned.

Loading content...

Implementors

Loading content...