Trait futures_util::compat::Stream01CompatExt
source · [−]pub trait Stream01CompatExt: Stream01 {
fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized,
{ ... }
}
Expand description
Extension trait for futures 0.1 Stream
Provided methods
fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized,
fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized,
Converts a futures 0.1
Stream<Item = T, Error = E>
into a futures 0.3
Stream<Item = Result<T, E>>
.
use futures::stream::StreamExt;
use futures_util::compat::Stream01CompatExt;
let stream = futures_01::stream::once::<u32, ()>(Ok(1));
let mut stream = stream.compat();
assert_eq!(stream.next().await, Some(Ok(1)));
assert_eq!(stream.next().await, None);