Skip to content

Commit 9242d18

Browse files
jplattepoljar
authored andcommitted
refactor: Use native async fn in traits for BackingStore
1 parent 59d632f commit 9242d18

File tree

5 files changed

+3
-12
lines changed

5 files changed

+3
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/matrix-sdk-base/src/event_cache/store/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ pub type Result<T, E = EventCacheStoreError> = std::result::Result<T, E>;
185185
#[derive(Clone, Debug)]
186186
struct LockableEventCacheStore(Arc<DynEventCacheStore>);
187187

188-
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
189-
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
190188
impl BackingStore for LockableEventCacheStore {
191189
type LockError = EventCacheStoreError;
192190

crates/matrix-sdk-common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ uniffi = ["dep:uniffi"]
2525
test-send-sync = []
2626

2727
[dependencies]
28-
async-trait.workspace = true
2928
eyeball-im.workspace = true
3029
futures-core.workspace = true
3130
futures-util.workspace = true

crates/matrix-sdk-common/src/store_locks.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
4040
use std::{
4141
error::Error,
42+
future::Future,
4243
sync::{
4344
atomic::{self, AtomicU32},
4445
Arc,
@@ -56,18 +57,16 @@ use crate::{
5657
};
5758

5859
/// Backing store for a cross-process lock.
59-
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
60-
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
6160
pub trait BackingStore {
6261
type LockError: Error + Send + Sync;
6362

6463
/// Try to take a lock using the given store.
65-
async fn try_lock(
64+
fn try_lock(
6665
&self,
6766
lease_duration_ms: u32,
6867
key: &str,
6968
holder: &str,
70-
) -> Result<bool, Self::LockError>;
69+
) -> impl Future<Output = Result<bool, Self::LockError>> + SendOutsideWasm;
7170
}
7271

7372
/// Small state machine to handle wait times.
@@ -369,8 +368,6 @@ mod tests {
369368
#[derive(Debug, thiserror::Error)]
370369
enum DummyError {}
371370

372-
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
373-
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
374371
impl BackingStore for TestStore {
375372
type LockError = DummyError;
376373

crates/matrix-sdk-crypto/src/store/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,8 +2138,6 @@ impl Deref for Store {
21382138
#[derive(Clone, Debug)]
21392139
pub struct LockableCryptoStore(Arc<dyn CryptoStore<Error = CryptoStoreError>>);
21402140

2141-
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
2142-
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
21432141
impl matrix_sdk_common::store_locks::BackingStore for LockableCryptoStore {
21442142
type LockError = CryptoStoreError;
21452143

0 commit comments

Comments
 (0)