Skip to main content

now

Function now 

Source
pub fn now() -> Instant
Expand description

The current instant of the runtime clock.

Equal to std::time::Instant::now() in a program. In a test with a paused tokio clock it is the virtual instant, so a rate limit that refills after one second refills when the test calls tokio::time::advance(Duration::from_secs(1)), without a real pause.

§Examples

use std::time::Duration;

let before = brokapi_runtime::now();
tokio::time::advance(Duration::from_secs(30)).await;
assert!(brokapi_runtime::now() - before >= Duration::from_secs(30));