[−][src]Struct fumio::timer::Interval
A stream representing notifications at fixed interval
Methods
impl Interval
[src]
pub fn new(at: Instant, duration: Duration) -> Interval
[src]
Create a new Interval
that starts at at
and yields every duration
interval after that.
Note that when it starts, it produces item too.
The duration
argument must be a non-zero duration.
Panics
This function panics if duration
is zero.
pub fn new_interval(duration: Duration) -> Interval
[src]
Creates new Interval
that yields with interval of duration
.
The function is shortcut for Interval::new(Instant::now() + duration, duration)
.
The duration
argument must be a non-zero duration.
Panics
This function panics if duration
is zero.
pub fn next(&'_ mut self) -> impl Future<Output = Option<Instant>>
[src]
Completes when the next instant in the interval has been reached.
Examples
#![feature(async_await)] use tokio::timer::Interval; use std::time::Duration; #[tokio::main] async fn main() { let mut interval = Interval::new_interval(Duration::from_millis(10)); interval.next().await; interval.next().await; interval.next().await; // approximately 30ms have elapsed. }
Trait Implementations
Auto Trait Implementations
impl Send for Interval
impl Unpin for Interval
impl Sync for Interval
impl !UnwindSafe for Interval
impl !RefUnwindSafe for Interval
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,