use {IntoFuture, Poll};
mod iter;
pub use self::iter::{iter, IterStream};
mod repeat;
pub use self::repeat::{repeat, Repeat};
mod and_then;
mod chain;
mod empty;
mod filter;
mod filter_map;
mod flatten;
mod fold;
mod for_each;
mod fuse;
mod future;
mod map;
mod map_err;
mod merge;
mod once;
mod or_else;
mod peek;
mod select;
mod skip;
mod skip_while;
mod take;
mod take_while;
mod then;
mod unfold;
mod zip;
mod forward;
pub use self::and_then::AndThen;
pub use self::chain::Chain;
pub use self::empty::{Empty, empty};
pub use self::filter::Filter;
pub use self::filter_map::FilterMap;
pub use self::flatten::Flatten;
pub use self::fold::Fold;
pub use self::for_each::ForEach;
pub use self::fuse::Fuse;
pub use self::future::StreamFuture;
pub use self::map::Map;
pub use self::map_err::MapErr;
pub use self::merge::{Merge, MergedItem};
pub use self::once::{Once, once};
pub use self::or_else::OrElse;
pub use self::peek::Peekable;
pub use self::select::Select;
pub use self::skip::Skip;
pub use self::skip_while::SkipWhile;
pub use self::take::Take;
pub use self::take_while::TakeWhile;
pub use self::then::Then;
pub use self::unfold::{Unfold, unfold};
pub use self::zip::Zip;
pub use self::forward::Forward;
use sink::{Sink};
if_std! {
use std;
mod buffered;
mod buffer_unordered;
mod catch_unwind;
mod chunks;
mod collect;
mod wait;
mod channel;
mod split;
mod futures_unordered;
pub use self::buffered::Buffered;
pub use self::buffer_unordered::BufferUnordered;
pub use self::catch_unwind::CatchUnwind;
pub use self::chunks::Chunks;
pub use self::collect::Collect;
pub use self::wait::Wait;
pub use self::split::{SplitStream, SplitSink};
pub use self::futures_unordered::{futures_unordered, FuturesUnordered};
#[doc(hidden)]
#[cfg(feature = "with-deprecated")]
#[allow(deprecated)]
pub use self::channel::{channel, Sender, Receiver, FutureSender, SendError};
pub type BoxStream<T, E> = ::std::boxed::Box<Stream<Item = T, Error = E> + Send>;
impl<S: ?Sized + Stream> Stream for ::std::boxed::Box<S> {
type Item = S::Item;
type Error = S::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
(**self).poll()
}
}
}
pub trait Stream {
type Item;
type Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>;
#[cfg(feature = "use_std")]
fn wait(self) -> Wait<Self>
where Self: Sized
{
wait::new(self)
}
#[cfg(feature = "use_std")]
fn boxed(self) -> BoxStream<Self::Item, Self::Error>
where Self: Sized + Send + 'static,
{
::std::boxed::Box::new(self)
}
fn into_future(self) -> StreamFuture<Self>
where Self: Sized
{
future::new(self)
}
fn map<U, F>(self, f: F) -> Map<Self, F>
where F: FnMut(Self::Item) -> U,
Self: Sized
{
map::new(self, f)
}
fn map_err<U, F>(self, f: F) -> MapErr<Self, F>
where F: FnMut(Self::Error) -> U,
Self: Sized
{
map_err::new(self, f)
}
fn filter<F>(self, f: F) -> Filter<Self, F>
where F: FnMut(&Self::Item) -> bool,
Self: Sized
{
filter::new(self, f)
}
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>
where F: FnMut(Self::Item) -> Option<B>,
Self: Sized
{
filter_map::new(self, f)
}
fn then<F, U>(self, f: F) -> Then<Self, F, U>
where F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Self: Sized
{
then::new(self, f)
}
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>
where F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Self: Sized
{
and_then::new(self, f)
}
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>
where F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Self: Sized
{
or_else::new(self, f)
}
#[cfg(feature = "use_std")]
fn collect(self) -> Collect<Self>
where Self: Sized
{
collect::new(self)
}
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>
where F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<Fut::Error>,
Self: Sized
{
fold::new(self, f, init)
}
fn flatten(self) -> Flatten<Self>
where Self::Item: Stream,
<Self::Item as Stream>::Error: From<Self::Error>,
Self: Sized
{
flatten::new(self)
}
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>
where P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item=bool, Error=Self::Error>,
Self: Sized
{
skip_while::new(self, pred)
}
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>
where P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item=bool, Error=Self::Error>,
Self: Sized
{
take_while::new(self, pred)
}
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>
where F: FnMut(Self::Item) -> U,
U: IntoFuture<Item=(), Error = Self::Error>,
Self: Sized
{
for_each::new(self, f)
}
fn take(self, amt: u64) -> Take<Self>
where Self: Sized
{
take::new(self, amt)
}
fn skip(self, amt: u64) -> Skip<Self>
where Self: Sized
{
skip::new(self, amt)
}
fn fuse(self) -> Fuse<Self>
where Self: Sized
{
fuse::new(self)
}
#[cfg(feature = "use_std")]
fn catch_unwind(self) -> CatchUnwind<Self>
where Self: Sized + std::panic::UnwindSafe
{
catch_unwind::new(self)
}
#[cfg(feature = "use_std")]
fn buffered(self, amt: usize) -> Buffered<Self>
where Self::Item: IntoFuture<Error = <Self as Stream>::Error>,
Self: Sized
{
buffered::new(self, amt)
}
#[cfg(feature = "use_std")]
fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self>
where Self::Item: IntoFuture<Error = <Self as Stream>::Error>,
Self: Sized
{
buffer_unordered::new(self, amt)
}
fn merge<S>(self, other: S) -> Merge<Self, S>
where S: Stream<Error = Self::Error>,
Self: Sized,
{
merge::new(self, other)
}
fn zip<S>(self, other: S) -> Zip<Self, S>
where S: Stream<Error = Self::Error>,
Self: Sized,
{
zip::new(self, other)
}
fn chain<S>(self, other: S) -> Chain<Self, S>
where S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized
{
chain::new(self, other)
}
fn peekable(self) -> Peekable<Self>
where Self: Sized
{
peek::new(self)
}
#[cfg(feature = "use_std")]
fn chunks(self, capacity: usize) -> Chunks<Self>
where Self: Sized
{
chunks::new(self, capacity)
}
fn select<S>(self, other: S) -> Select<Self, S>
where S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized,
{
select::new(self, other)
}
fn forward<S>(self, sink: S) -> Forward<Self, S>
where S: Sink<SinkItem = Self::Item>,
Self::Error: From<S::SinkError>,
Self: Sized
{
forward::new(self, sink)
}
#[cfg(feature = "use_std")]
fn split(self) -> (SplitSink<Self>, SplitStream<Self>)
where Self: super::sink::Sink + Sized
{
split::split(self)
}
}
impl<'a, S: ?Sized + Stream> Stream for &'a mut S {
type Item = S::Item;
type Error = S::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
(**self).poll()
}
}