summaryrefslogtreecommitdiffstats
path: root/tokio/src/timer/clock/now.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/src/timer/clock/now.rs')
-rw-r--r--tokio/src/timer/clock/now.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tokio/src/timer/clock/now.rs b/tokio/src/timer/clock/now.rs
new file mode 100644
index 00000000..f6b11b70
--- /dev/null
+++ b/tokio/src/timer/clock/now.rs
@@ -0,0 +1,15 @@
+use std::time::Instant;
+
+/// Returns [`Instant`] values representing the current instant in time.
+///
+/// This allows customizing the source of time which is especially useful for
+/// testing.
+///
+/// Implementations must ensure that calls to `now` return monotonically
+/// increasing [`Instant`] values.
+///
+/// [`Instant`]: std::time::Instant
+pub trait Now: Send + Sync + 'static {
+ /// Returns an instant corresponding to "now".
+ fn now(&self) -> Instant;
+}