[][src]Struct runtime::time::Interval

#[must_use = "streams do nothing unless polled"]
pub struct Interval { /* fields omitted */ }

A stream representing notifications at a fixed interval.

Methods

impl Interval[src]

pub fn new(dur: Duration) -> Self[src]

Create a stream that fires events at a set interval.

Examples

use runtime::time::Interval;
use std::time::{Duration, Instant};

let start = Instant::now();
let mut interval = Interval::new(Duration::from_millis(10)).take(3);
while let Some(now) = interval.next().await {
    println!("{}ms have elapsed", (now - start).as_millis());
}

assert!(Instant::now() - start >= Duration::from_millis(30));

Trait Implementations

impl Debug for Interval[src]

impl Stream for Interval[src]

type Item = Instant

Values yielded by the stream.

Auto Trait Implementations

impl Send for Interval

impl !Sync for Interval

impl Unpin for Interval

impl !UnwindSafe for Interval

impl !RefUnwindSafe for Interval

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]