Use wasm32 cfg flag for kvs (#3131)

Co-authored-by: Emmanuel Keller <emmanuel.keller@surrealdb.com>
Co-authored-by: Tobie Morgan Hitchcock <tobie@surrealdb.com>
This commit is contained in:
Tony Giorgio 2023-12-19 03:47:35 -06:00 committed by GitHub
parent 953e496e7d
commit 7e25b36765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,10 @@
use crate::dbs::node::Timestamp; use crate::dbs::node::Timestamp;
use crate::sql; use crate::sql;
use sql::Duration; use sql::Duration;
#[cfg(not(target_arch = "wasm32"))]
use std::time::{SystemTime, UNIX_EPOCH}; 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 // Traits cannot have async and we need sized structs for Clone + Send + Sync
#[allow(dead_code)] #[allow(dead_code)]
@ -103,3 +106,14 @@ impl Default for SystemClock {
Self::new() Self::new()
} }
} }
#[cfg(test)]
mod tests {
use crate::kvs::clock::SystemClock;
#[test]
fn get_clock_now() {
let clock = SystemClock::new();
let _ = clock.now();
}
}