Struct async_sleep::impl_async_io::AsyncIoTimer
source · pub struct AsyncIoTimer { /* private fields */ }
Expand description
A future or stream that emits timed events.
Timers are futures that output a single Instant
when they fire.
Timers are also streams that can output Instant
s periodically.
Precision
There is a limit on the maximum precision that a Timer
can provide. This limit is
dependent on the current platform; for instance, on Windows, the maximum precision is
about 16 milliseconds. Because of this limit, the timer may sleep for longer than the
requested duration. It will never sleep for less.
Examples
Sleep for 1 second:
use async_io::Timer;
use std::time::Duration;
Timer::after(Duration::from_secs(1)).await;
Timeout after 1 second:
use async_io::Timer;
use futures_lite::FutureExt;
use std::time::Duration;
let addrs = async_net::resolve("google.com:80")
.or(async {
Timer::after(Duration::from_secs(10)).await;
Err(std::io::ErrorKind::TimedOut.into())
})
.await?;
Implementations§
source§impl Timer
impl Timer
sourcepub fn never() -> Timer ⓘ
pub fn never() -> Timer ⓘ
Creates a timer that will never fire.
Examples
This function may also be useful for creating a function with an optional timeout.
use async_io::Timer;
use futures_lite::prelude::*;
use std::time::Duration;
async fn run_with_timeout(timeout: Option<Duration>) {
let timer = timeout
.map(|timeout| Timer::after(timeout))
.unwrap_or_else(Timer::never);
run_lengthy_operation().or(timer).await;
}
// Times out after 5 seconds.
run_with_timeout(Some(Duration::from_secs(5))).await;
// Does not time out.
run_with_timeout(None).await;
sourcepub fn after(duration: Duration) -> Timer ⓘ
pub fn after(duration: Duration) -> Timer ⓘ
Creates a timer that emits an event once after the given duration of time.
Examples
use async_io::Timer;
use std::time::Duration;
Timer::after(Duration::from_secs(1)).await;
sourcepub fn at(instant: Instant) -> Timer ⓘ
pub fn at(instant: Instant) -> Timer ⓘ
Creates a timer that emits an event once at the given time instant.
Examples
use async_io::Timer;
use std::time::{Duration, Instant};
let now = Instant::now();
let when = now + Duration::from_secs(1);
Timer::at(when).await;
sourcepub fn interval(period: Duration) -> Timer ⓘ
pub fn interval(period: Duration) -> Timer ⓘ
Creates a timer that emits events periodically.
Examples
use async_io::Timer;
use futures_lite::StreamExt;
use std::time::{Duration, Instant};
let period = Duration::from_secs(1);
Timer::interval(period).next().await;
sourcepub fn interval_at(start: Instant, period: Duration) -> Timer ⓘ
pub fn interval_at(start: Instant, period: Duration) -> Timer ⓘ
Creates a timer that emits events periodically, starting at start
.
Examples
use async_io::Timer;
use futures_lite::StreamExt;
use std::time::{Duration, Instant};
let start = Instant::now();
let period = Duration::from_secs(1);
Timer::interval_at(start, period).next().await;
sourcepub fn will_fire(&self) -> bool
pub fn will_fire(&self) -> bool
Indicates whether or not this timer will ever fire.
[never()
] will never fire, and timers created with [after()
] or [at()
] will fire
if the duration is not too large.
Examples
use async_io::Timer;
use std::time::Duration;
// `never` will never fire.
assert!(!Timer::never().will_fire());
// `after` will fire if the duration is not too large.
assert!(Timer::after(Duration::from_secs(1)).will_fire());
assert!(!Timer::after(Duration::MAX).will_fire());
sourcepub fn set_after(&mut self, duration: Duration)
pub fn set_after(&mut self, duration: Duration)
Sets the timer to emit an en event once after the given duration of time.
Note that resetting a timer is different from creating a new timer because
set_after()
does not remove the waker associated with the task
that is polling the timer.
Examples
use async_io::Timer;
use std::time::Duration;
let mut t = Timer::after(Duration::from_secs(1));
t.set_after(Duration::from_millis(100));
sourcepub fn set_at(&mut self, instant: Instant)
pub fn set_at(&mut self, instant: Instant)
Sets the timer to emit an event once at the given time instant.
Note that resetting a timer is different from creating a new timer because
set_at()
does not remove the waker associated with the task
that is polling the timer.
Examples
use async_io::Timer;
use std::time::{Duration, Instant};
let mut t = Timer::after(Duration::from_secs(1));
let now = Instant::now();
let when = now + Duration::from_secs(1);
t.set_at(when);
sourcepub fn set_interval(&mut self, period: Duration)
pub fn set_interval(&mut self, period: Duration)
Sets the timer to emit events periodically.
Note that resetting a timer is different from creating a new timer because
set_interval()
does not remove the waker associated with the
task that is polling the timer.
Examples
use async_io::Timer;
use futures_lite::StreamExt;
use std::time::{Duration, Instant};
let mut t = Timer::after(Duration::from_secs(1));
let period = Duration::from_secs(2);
t.set_interval(period);
sourcepub fn set_interval_at(&mut self, start: Instant, period: Duration)
pub fn set_interval_at(&mut self, start: Instant, period: Duration)
Sets the timer to emit events periodically, starting at start
.
Note that resetting a timer is different from creating a new timer because
set_interval_at()
does not remove the waker associated with
the task that is polling the timer.
Examples
use async_io::Timer;
use futures_lite::StreamExt;
use std::time::{Duration, Instant};
let mut t = Timer::after(Duration::from_secs(1));
let start = Instant::now();
let period = Duration::from_secs(2);
t.set_interval_at(start, period);
Trait Implementations§
source§impl Stream for Timer
impl Stream for Timer
Auto Trait Implementations§
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<F> FutureExt for Fwhere
F: Future + ?Sized,
impl<F> FutureExt for Fwhere F: Future + ?Sized,
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where Self: Sized + UnwindSafe,
source§impl<T> FutureExt for Twhere
T: Future + ?Sized,
impl<T> FutureExt for Twhere T: Future + ?Sized,
source§fn map<U, F>(self, f: F) -> Map<Self, F>where
F: FnOnce(Self::Output) -> U,
Self: Sized,
fn map<U, F>(self, f: F) -> Map<Self, F>where F: FnOnce(Self::Output) -> U, Self: Sized,
source§fn map_into<U>(self) -> MapInto<Self, U>where
Self::Output: Into<U>,
Self: Sized,
fn map_into<U>(self) -> MapInto<Self, U>where Self::Output: Into<U>, Self: Sized,
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
Self: Sized,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where F: FnOnce(Self::Output) -> Fut, Fut: Future, Self: Sized,
f
. Read moresource§fn left_future<B>(self) -> Either<Self, B>where
B: Future<Output = Self::Output>,
Self: Sized,
fn left_future<B>(self) -> Either<Self, B>where B: Future<Output = Self::Output>, Self: Sized,
source§fn right_future<A>(self) -> Either<A, Self>where
A: Future<Output = Self::Output>,
Self: Sized,
fn right_future<A>(self) -> Either<A, Self>where A: Future<Output = Self::Output>, Self: Sized,
source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where Self: Sized,
source§fn flatten(self) -> Flatten<Self>where
Self::Output: Future,
Self: Sized,
fn flatten(self) -> Flatten<Self>where Self::Output: Future, Self: Sized,
source§fn flatten_stream(self) -> FlattenStream<Self>where
Self::Output: Stream,
Self: Sized,
fn flatten_stream(self) -> FlattenStream<Self>where Self::Output: Stream, Self: Sized,
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moresource§fn inspect<F>(self, f: F) -> Inspect<Self, F>where
F: FnOnce(&Self::Output),
Self: Sized,
fn inspect<F>(self, f: F) -> Inspect<Self, F>where F: FnOnce(&Self::Output), Self: Sized,
source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where Self: Sized + UnwindSafe,
source§fn boxed<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>>where
Self: Sized + Send + 'a,
fn boxed<'a>( self ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>>where Self: Sized + Send + 'a,
source§fn boxed_local<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>>where
Self: Sized + 'a,
fn boxed_local<'a>( self ) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>>where Self: Sized + 'a,
source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere F: Future,
§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
§impl<S> StreamExt for Swhere
S: Stream + ?Sized,
impl<S> StreamExt for Swhere S: Stream + ?Sized,
§fn next(&mut self) -> NextFuture<'_, Self>where
Self: Unpin,
fn next(&mut self) -> NextFuture<'_, Self>where Self: Unpin,
§fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>where
Self: Stream<Item = Result<T, E>> + Unpin,
fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>where Self: Stream<Item = Result<T, E>> + Unpin,
§fn count(self) -> CountFuture<Self>where
Self: Sized,
fn count(self) -> CountFuture<Self>where Self: Sized,
§fn map<T, F>(self, f: F) -> Map<Self, F>where
Self: Sized,
F: FnMut(Self::Item) -> T,
fn map<T, F>(self, f: F) -> Map<Self, F>where Self: Sized, F: FnMut(Self::Item) -> T,
§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where
Self: Sized,
U: Stream,
F: FnMut(Self::Item) -> U,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where Self: Sized, U: Stream, F: FnMut(Self::Item) -> U,
§fn flatten(self) -> Flatten<Self>where
Self: Sized,
Self::Item: Stream,
fn flatten(self) -> Flatten<Self>where Self: Sized, Self::Item: Stream,
§fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>where
Self: Sized,
F: FnMut(Self::Item) -> Fut,
Fut: Future,
fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>where Self: Sized, F: FnMut(Self::Item) -> Fut, Fut: Future,
§fn filter<P>(self, predicate: P) -> Filter<Self, P>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn filter<P>(self, predicate: P) -> Filter<Self, P>where Self: Sized, P: FnMut(&Self::Item) -> bool,
§fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>where
Self: Sized,
F: FnMut(Self::Item) -> Option<T>,
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>where Self: Sized, F: FnMut(Self::Item) -> Option<T>,
§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where Self: Sized,
n
items of the stream. Read more§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>where Self: Sized, P: FnMut(&Self::Item) -> bool,
§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where Self: Sized,
n
items of the stream. Read more§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>where Self: Sized, P: FnMut(&Self::Item) -> bool,
§fn chain<U>(self, other: U) -> Chain<Self, U>where
Self: Sized,
U: Stream<Item = Self::Item>,
fn chain<U>(self, other: U) -> Chain<Self, U>where Self: Sized, U: Stream<Item = Self::Item>,
§fn cloned<'a, T>(self) -> Cloned<Self>where
Self: Stream<Item = &'a T> + Sized,
T: Clone + 'a,
fn cloned<'a, T>(self) -> Cloned<Self>where Self: Stream<Item = &'a T> + Sized, T: Clone + 'a,
§fn copied<'a, T>(self) -> Copied<Self>where
Self: Stream<Item = &'a T> + Sized,
T: Copy + 'a,
fn copied<'a, T>(self) -> Copied<Self>where Self: Stream<Item = &'a T> + Sized, T: Copy + 'a,
§fn collect<C>(self) -> CollectFuture<Self, C>where
Self: Sized,
C: Default + Extend<Self::Item>,
fn collect<C>(self) -> CollectFuture<Self, C>where Self: Sized, C: Default + Extend<Self::Item>,
§fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>where
Self: Stream<Item = Result<T, E>> + Sized,
C: Default + Extend<T>,
fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>where Self: Stream<Item = Result<T, E>> + Sized, C: Default + Extend<T>,
§fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>where
Self: Sized,
B: Default + Extend<Self::Item>,
P: FnMut(&Self::Item) -> bool,
fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>where Self: Sized, B: Default + Extend<Self::Item>, P: FnMut(&Self::Item) -> bool,
predicate
is true
and those for which it is
false
, and then collects them into two collections. Read more§fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>where
Self: Sized,
F: FnMut(T, Self::Item) -> T,
fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>where Self: Sized, F: FnMut(T, Self::Item) -> T,
§fn try_fold<T, E, F, B>(
&mut self,
init: B,
f: F
) -> TryFoldFuture<'_, Self, F, B>where
Self: Stream<Item = Result<T, E>> + Unpin + Sized,
F: FnMut(B, T) -> Result<B, E>,
fn try_fold<T, E, F, B>( &mut self, init: B, f: F ) -> TryFoldFuture<'_, Self, F, B>where Self: Stream<Item = Result<T, E>> + Unpin + Sized, F: FnMut(B, T) -> Result<B, E>,
§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>where
Self: Sized,
F: FnMut(&mut St, Self::Item) -> Option<B>,
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
§fn cycle(self) -> Cycle<Self>where
Self: Clone + Sized,
fn cycle(self) -> Cycle<Self>where Self: Clone + Sized,
§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where Self: Sized,
(index, item)
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>where
Self: Sized,
F: FnMut(&Self::Item),
fn inspect<F>(self, f: F) -> Inspect<Self, F>where Self: Sized, F: FnMut(&Self::Item),
§fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where
Self: Unpin,
fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where Self: Unpin,
n
th item of the stream. Read more§fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>where
Self: Unpin,
P: FnMut(&Self::Item) -> bool,
fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>where Self: Unpin, P: FnMut(&Self::Item) -> bool,
§fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>where
Self: Unpin,
F: FnMut(Self::Item) -> Option<B>,
fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>where Self: Unpin, F: FnMut(Self::Item) -> Option<B>,
§fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>where Self: Unpin, P: FnMut(Self::Item) -> bool,
§fn all<P>(&mut self, predicate: P) -> AllFuture<'_, Self, P>where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn all<P>(&mut self, predicate: P) -> AllFuture<'_, Self, P>where Self: Unpin, P: FnMut(Self::Item) -> bool,
§fn any<P>(&mut self, predicate: P) -> AnyFuture<'_, Self, P>where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn any<P>(&mut self, predicate: P) -> AnyFuture<'_, Self, P>where Self: Unpin, P: FnMut(Self::Item) -> bool,
§fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>where
Self: Sized,
F: FnMut(Self::Item),
fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>where Self: Sized, F: FnMut(Self::Item),
§fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>where
Self: Unpin,
F: FnMut(Self::Item) -> Result<(), E>,
fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>where Self: Unpin, F: FnMut(Self::Item) -> Result<(), E>,
§fn zip<U>(self, other: U) -> Zip<Self, U>where
Self: Sized,
U: Stream,
fn zip<U>(self, other: U) -> Zip<Self, U>where Self: Sized, U: Stream,
§fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Stream<Item = (A, B)> + Sized,
fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Stream<Item = (A, B)> + Sized,
§fn race<S>(self, other: S) -> Race<Self, S>where
Self: Sized,
S: Stream<Item = Self::Item>,
fn race<S>(self, other: S) -> Race<Self, S>where Self: Sized, S: Stream<Item = Self::Item>,
other
stream, with no preference for either stream when both are ready. Read moresource§impl<T> StreamExt for Twhere
T: Stream + ?Sized,
impl<T> StreamExt for Twhere T: Stream + ?Sized,
source§fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
fn next(&mut self) -> Next<'_, Self>where Self: Unpin,
source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized + Unpin,
fn into_future(self) -> StreamFuture<Self>where Self: Sized + Unpin,
source§fn map<T, F>(self, f: F) -> Map<Self, F>where
F: FnMut(Self::Item) -> T,
Self: Sized,
fn map<T, F>(self, f: F) -> Map<Self, F>where F: FnMut(Self::Item) -> T, Self: Sized,
source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where Self: Sized,
source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,
source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
Self: Sized,
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = Option<T>>, Self: Sized,
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
Self: Sized,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future, Self: Sized,
source§fn collect<C>(self) -> Collect<Self, C>where
C: Default + Extend<Self::Item>,
Self: Sized,
fn collect<C>(self) -> Collect<Self, C>where C: Default + Extend<Self::Item>, Self: Sized,
source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Stream<Item = (A, B)>,
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Sized + Stream<Item = (A, B)>,
source§fn concat(self) -> Concat<Self>where
Self: Sized,
Self::Item: Extend<<Self::Item as IntoIterator>::Item> + IntoIterator + Default,
fn concat(self) -> Concat<Self>where Self: Sized, Self::Item: Extend<<Self::Item as IntoIterator>::Item> + IntoIterator + Default,
source§fn count(self) -> Count<Self>where
Self: Sized,
fn count(self) -> Count<Self>where Self: Sized,
source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
Self: Sized,
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where F: FnMut(T, Self::Item) -> Fut, Fut: Future<Output = T>, Self: Sized,
source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,
true
if any element in stream satisfied a predicate. Read moresource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,
true
if all element in stream satisfied a predicate. Read moresource§fn flatten(self) -> Flatten<Self>where
Self::Item: Stream,
Self: Sized,
fn flatten(self) -> Flatten<Self>where Self::Item: Stream, Self: Sized,
source§fn flatten_unordered(
self,
limit: impl Into<Option<usize>>
) -> FlattenUnorderedWithFlowController<Self, ()>where
Self::Item: Stream + Unpin,
Self: Sized,
fn flatten_unordered( self, limit: impl Into<Option<usize>> ) -> FlattenUnorderedWithFlowController<Self, ()>where Self::Item: Stream + Unpin, Self: Sized,
source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where
F: FnMut(Self::Item) -> U,
U: Stream,
Self: Sized,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where F: FnMut(Self::Item) -> U, U: Stream, Self: Sized,
source§fn flat_map_unordered<U, F>(
self,
limit: impl Into<Option<usize>>,
f: F
) -> FlatMapUnordered<Self, U, F>where
U: Stream + Unpin,
F: FnMut(Self::Item) -> U,
Self: Sized,
fn flat_map_unordered<U, F>( self, limit: impl Into<Option<usize>>, f: F ) -> FlatMapUnordered<Self, U, F>where U: Stream + Unpin, F: FnMut(Self::Item) -> U, Self: Sized,
StreamExt::map
but flattens nested Stream
s
and polls them concurrently, yielding items in any order, as they made
available. Read moresource§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
Self: Sized,
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where F: FnMut(&mut S, Self::Item) -> Fut, Fut: Future<Output = Option<B>>, Self: Sized,
StreamExt::fold
that holds internal state
and produces a new stream. Read moresource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,
true
. Read moresource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,
true
. Read moresource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where
Fut: Future,
Self: Sized,
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where Fut: Future, Self: Sized,
source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
Self: Sized,
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = ()>, Self: Sized,
source§fn for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F
) -> ForEachConcurrent<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
Self: Sized,
fn for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F ) -> ForEachConcurrent<Self, Fut, F>where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = ()>, Self: Sized,
source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where Self: Sized,
n
items of the underlying stream. Read moresource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where Self: Sized,
n
items of the underlying stream. Read moresource§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where Self: Sized + UnwindSafe,
source§fn boxed<'a>(
self
) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>where
Self: Sized + Send + 'a,
fn boxed<'a>( self ) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>where Self: Sized + Send + 'a,
source§fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>where Self: Sized + 'a,
source§fn buffered(self, n: usize) -> Buffered<Self>where
Self::Item: Future,
Self: Sized,
fn buffered(self, n: usize) -> Buffered<Self>where Self::Item: Future, Self: Sized,
source§fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>where
Self::Item: Future,
Self: Sized,
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>where Self::Item: Future, Self: Sized,
source§fn zip<St>(self, other: St) -> Zip<Self, St>where
St: Stream,
Self: Sized,
fn zip<St>(self, other: St) -> Zip<Self, St>where St: Stream, Self: Sized,
source§fn chain<St>(self, other: St) -> Chain<Self, St>where
St: Stream<Item = Self::Item>,
Self: Sized,
fn chain<St>(self, other: St) -> Chain<Self, St>where St: Stream<Item = Self::Item>, Self: Sized,
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where Self: Sized,
peek
method. Read moresource§fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, capacity: usize) -> Chunks<Self>where Self: Sized,
source§fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where Self: Sized,
source§fn inspect<F>(self, f: F) -> Inspect<Self, F>where
F: FnMut(&Self::Item),
Self: Sized,
fn inspect<F>(self, f: F) -> Inspect<Self, F>where F: FnMut(&Self::Item), Self: Sized,
source§fn left_stream<B>(self) -> Either<Self, B>where
B: Stream<Item = Self::Item>,
Self: Sized,
fn left_stream<B>(self) -> Either<Self, B>where B: Stream<Item = Self::Item>, Self: Sized,
source§fn right_stream<B>(self) -> Either<B, Self>where
B: Stream<Item = Self::Item>,
Self: Sized,
fn right_stream<B>(self) -> Either<B, Self>where B: Stream<Item = Self::Item>, Self: Sized,
source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where Self: Unpin,
Stream::poll_next
] on Unpin
stream types.