From 7e25b36765f57de35d70afbc401462ca3341f20c Mon Sep 17 00:00:00 2001 From: Tony Giorgio <101225832+TonyGiorgio@users.noreply.github.com> Date: Tue, 19 Dec 2023 03:47:35 -0600 Subject: [PATCH] Use wasm32 cfg flag for kvs (#3131) Co-authored-by: Emmanuel Keller Co-authored-by: Tobie Morgan Hitchcock --- lib/src/kvs/clock.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/kvs/clock.rs b/lib/src/kvs/clock.rs index d96b0c90..7bc21e98 100644 --- a/lib/src/kvs/clock.rs +++ b/lib/src/kvs/clock.rs @@ -1,7 +1,10 @@ use crate::dbs::node::Timestamp; use crate::sql; use sql::Duration; +#[cfg(not(target_arch = "wasm32"))] use std::time::{SystemTime, UNIX_EPOCH}; +#[cfg(target_arch = "wasm32")] +use wasmtimer::std::{SystemTime, UNIX_EPOCH}; // Traits cannot have async and we need sized structs for Clone + Send + Sync #[allow(dead_code)] @@ -103,3 +106,14 @@ impl Default for SystemClock { Self::new() } } + +#[cfg(test)] +mod tests { + use crate::kvs::clock::SystemClock; + + #[test] + fn get_clock_now() { + let clock = SystemClock::new(); + let _ = clock.now(); + } +}