From 2a411bf5df170eef57ff51452cc1e0da5c38203b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 12 May 2020 14:28:01 +0200 Subject: [PATCH] matrix-sdk: Use the instant crate so Instant works on wasm as well. --- matrix_sdk/src/client.rs | 2 +- matrix_sdk_common/Cargo.toml | 3 ++- matrix_sdk_common/src/lib.rs | 1 + matrix_sdk_crypto/src/olm.rs | 2 +- matrix_sdk_crypto/src/store/sqlite.rs | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 9e176591..b1ad3c9a 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -19,8 +19,8 @@ use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; use std::result::Result as StdResult; use std::sync::Arc; -use std::time::{Duration, Instant}; +use matrix_sdk_common::instant::{Duration, Instant}; use matrix_sdk_common::locks::RwLock; use matrix_sdk_common::uuid::Uuid; diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index 8d28a3e7..a4875493 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -16,6 +16,7 @@ ruma-api = "0.16.0" ruma-client-api = "0.8.0" ruma-events = "0.21.0" ruma-identifiers = "0.16.1" +instant = { version = "0.1.3", features = ["wasm-bindgen", "now"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] uuid = { version = "0.8.1", features = ["v4"] } @@ -27,4 +28,4 @@ features = ["sync", "time", "fs"] [target.'cfg(target_arch = "wasm32")'.dependencies] futures-locks = { git = "https://github.com/asomers/futures-locks", default-features = false } -uuid = { version = "0.8.1", features = ["v4", "wasm-bindgen"] } \ No newline at end of file +uuid = { version = "0.8.1", features = ["v4", "wasm-bindgen"] } diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index 38653e22..42cce581 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -1,3 +1,4 @@ +pub use instant; pub use js_int; pub use ruma_api::{ error::{FromHttpResponseError, IntoHttpError, ServerError}, diff --git a/matrix_sdk_crypto/src/olm.rs b/matrix_sdk_crypto/src/olm.rs index e8566ce9..5e09ead1 100644 --- a/matrix_sdk_crypto/src/olm.rs +++ b/matrix_sdk_crypto/src/olm.rs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +use matrix_sdk_common::instant::Instant; use std::fmt; use std::mem; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::Arc; -use std::time::Instant; use matrix_sdk_common::locks::Mutex; use serde::Serialize; diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 8fd98228..922bebb1 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +use matrix_sdk_common::instant::{Duration, Instant}; use std::collections::{BTreeMap, HashSet}; use std::convert::TryFrom; use std::mem; use std::path::{Path, PathBuf}; use std::result::Result as StdResult; use std::sync::Arc; -use std::time::{Duration, Instant}; use url::Url; use async_trait::async_trait;