2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-12 03:16:43 +00:00
async-std/src/stream/from_stream.rs
Yoshua Wuyts bfb16790c3
Update src/stream/from_stream.rs
Co-Authored-By: Stjepan Glavina <stjepang@gmail.com>
2019-09-18 12:42:58 +02:00

30 lines
861 B
Rust

use super::IntoStream;
use std::pin::Pin;
/// 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`].
///
/// [`IntoStream`]: trait.IntoStream.html
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(any(feature = "unstable", feature = "docs"))]
pub trait FromStream<T: Send> {
/// Creates a value from a stream.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// // use async_std::stream::FromStream;
///
/// // let _five_fives = async_std::stream::repeat(5).take(5);
/// ```
fn from_stream<'a, S: IntoStream<Item = T> + Send + 'a>(
stream: S,
) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>>;
}