Skip to content

Commit ac6b065

Browse files
Daniel SalinasDaniel Salinas
authored andcommitted
Restore some marker traits that were needed still
1 parent 246d70e commit ac6b065

File tree

18 files changed

+63
-54
lines changed

18 files changed

+63
-54
lines changed

crates/matrix-sdk-base/src/event_cache_store/traits.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::{fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
18+
use matrix_sdk_common::AsyncTraitDeps;
1819
use ruma::MxcUri;
1920

2021
use super::EventCacheStoreError;
@@ -24,7 +25,7 @@ use crate::media::MediaRequest;
2425
/// for the event cache of the SDK.
2526
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
2627
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
27-
pub trait EventCacheStore: Send + Sync {
28+
pub trait EventCacheStore: AsyncTraitDeps {
2829
/// The error type used by this event cache store.
2930
type Error: fmt::Debug + Into<EventCacheStoreError>;
3031

crates/matrix-sdk-base/src/read_receipts.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ use std::{
123123
};
124124

125125
use eyeball_im::Vector;
126-
use matrix_sdk_common::{deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer};
126+
use matrix_sdk_common::{
127+
deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer, SendOutsideWasm,
128+
SyncOutsideWasm,
129+
};
127130
use ruma::{
128131
events::{
129132
poll::{start::PollStartEventContent, unstable_start::UnstablePollStartEventContent},
@@ -266,16 +269,7 @@ impl RoomReadReceipts {
266269
}
267270

268271
/// Provider for timeline events prior to the current sync.
269-
#[cfg(not(target_arch = "wasm32"))]
270-
pub trait PreviousEventsProvider: Send + Sync {
271-
/// Returns the list of known timeline events, in sync order, for the given
272-
/// room.
273-
fn for_room(&self, room_id: &RoomId) -> Vector<SyncTimelineEvent>;
274-
}
275-
276-
/// Provider for timeline events prior to the current sync.
277-
#[cfg(target_arch = "wasm32")]
278-
pub trait PreviousEventsProvider {
272+
pub trait PreviousEventsProvider: SendOutsideWasm + SyncOutsideWasm {
279273
/// Returns the list of known timeline events, in sync order, for the given
280274
/// room.
281275
fn for_room(&self, room_id: &RoomId) -> Vector<SyncTimelineEvent>;

crates/matrix-sdk-base/src/store/memory_store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ impl MemoryStore {
137137
}
138138
}
139139

140-
#[async_trait]
140+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
141+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
141142
impl StateStore for MemoryStore {
142143
type Error = StoreError;
143144

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ use tokio::sync::{broadcast, Mutex, RwLock};
5858
use tracing::warn;
5959

6060
use crate::{
61-
event_cache_store::{DynEventCacheStore, IntoEventCacheStore},
62-
rooms::{normal::RoomInfoNotableUpdate, RoomInfo, RoomState},
63-
MinimalRoomMemberEvent, Room, RoomStateFilter, SessionMeta
61+
event_cache_store::{DynEventCacheStore, IntoEventCacheStore},
62+
rooms::{normal::RoomInfoNotableUpdate, RoomInfo, RoomState},
63+
MinimalRoomMemberEvent, Room, RoomStateFilter, SessionMeta,
6464
};
6565

6666
pub(crate) mod ambiguity_map;

crates/matrix-sdk-base/src/store/observable_map.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ mod impl_non_wasm32 {
136136
#[cfg(target_arch = "wasm32")]
137137
mod impl_wasm32 {
138138
use std::{borrow::Borrow, collections::BTreeMap, hash::Hash};
139-
use futures_util::stream;
140-
use futures_util::{Stream, StreamExt};
139+
141140
use eyeball_im::{Vector, VectorDiff};
141+
use futures_util::{stream, Stream, StreamExt};
142142

143143
/// An observable map for Wasm. It's a simple wrapper around `BTreeMap`.
144144
#[derive(Debug)]
@@ -191,7 +191,8 @@ mod impl_wasm32 {
191191
/// Get a [`Stream`] of the values.
192192
pub(crate) fn stream(&self) -> (Vector<V>, impl Stream<Item = Vec<VectorDiff<V>>>) {
193193
let values: Vector<V> = self.0.values().cloned().collect();
194-
let stream = stream::iter(vec![values.clone()]).map(|v| vec![VectorDiff::Reset{ values: v }]);
194+
let stream =
195+
stream::iter(vec![values.clone()]).map(|v| vec![VectorDiff::Reset { values: v }]);
195196
(values, stream)
196197
}
197198
}

crates/matrix-sdk-base/src/store/traits.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::{
2323
use as_variant::as_variant;
2424
use async_trait::async_trait;
2525
use growable_bloom_filter::GrowableBloom;
26+
use matrix_sdk_common::AsyncTraitDeps;
2627
use ruma::{
2728
api::MatrixVersion,
2829
events::{
@@ -49,8 +50,9 @@ use crate::{
4950

5051
/// An abstract state store trait that can be used to implement different stores
5152
/// for the SDK.
52-
#[async_trait]
53-
pub trait StateStore: fmt::Debug + Send + Sync {
53+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
54+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
55+
pub trait StateStore: AsyncTraitDeps {
5456
/// The error type used by this state store.
5557
type Error: fmt::Debug + Into<StoreError> + From<serde_json::Error>;
5658

@@ -450,7 +452,8 @@ impl<T: fmt::Debug> fmt::Debug for EraseStateStoreError<T> {
450452
}
451453
}
452454

453-
#[async_trait]
455+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
456+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
454457
impl<T: StateStore> StateStore for EraseStateStoreError<T> {
455458
type Error = StoreError;
456459

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ use std::{
2020
task::{Context, Poll},
2121
};
2222

23-
use futures_util::FutureExt;
2423
#[cfg(target_arch = "wasm32")]
2524
pub use futures_util::future::Aborted as JoinError;
2625
#[cfg(target_arch = "wasm32")]
2726
use futures_util::future::{AbortHandle, Abortable, RemoteHandle};
27+
use futures_util::FutureExt;
2828
#[cfg(not(target_arch = "wasm32"))]
2929
pub use tokio::task::{spawn, JoinError, JoinHandle};
3030

31-
3231
/// A `Box::pin` future that is `Send` on non-wasm, and without `Send` on wasm.
3332
#[cfg(target_arch = "wasm32")]
3433
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>;
3534
#[cfg(not(target_arch = "wasm32"))]
3635
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
3736

38-
3937
#[cfg(target_arch = "wasm32")]
4038
pub fn spawn<F, T>(future: F) -> JoinHandle<T>
4139
where

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ impl MemoryStore {
194194

195195
type Result<T> = std::result::Result<T, Infallible>;
196196

197-
#[async_trait]
197+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
198+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
198199
impl CryptoStore for MemoryStore {
199200
type Error = Infallible;
200201

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::{collections::HashMap, fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
18+
use matrix_sdk_common::AsyncTraitDeps;
1819
use ruma::{
1920
events::secret::request::SecretName, DeviceId, OwnedDeviceId, RoomId, TransactionId, UserId,
2021
};
@@ -36,8 +37,9 @@ use crate::{
3637

3738
/// Represents a store that the `OlmMachine` uses to store E2EE data (such as
3839
/// cryptographic keys).
39-
#[async_trait]
40-
pub trait CryptoStore: fmt::Debug + Send + Sync {
40+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
41+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
42+
pub trait CryptoStore: AsyncTraitDeps {
4143
/// The error type used by this crypto store.
4244
type Error: fmt::Debug + Into<CryptoStoreError>;
4345

@@ -367,7 +369,8 @@ impl<T: fmt::Debug> fmt::Debug for EraseCryptoStoreError<T> {
367369
}
368370
}
369371

370-
#[async_trait]
372+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
373+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
371374
impl<T: CryptoStore> CryptoStore for EraseCryptoStoreError<T> {
372375
type Error = CryptoStoreError;
373376

crates/matrix-sdk-ui/src/sync_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use eyeball::{SharedObservable, Subscriber};
2929
use futures_core::Future;
3030
use futures_util::{pin_mut, StreamExt as _};
3131
use matrix_sdk::Client;
32-
use thiserror::Error;
3332
use matrix_sdk_base::executor::{spawn, JoinHandle};
33+
use thiserror::Error;
3434
use tokio::sync::{
3535
mpsc::{Receiver, Sender},
3636
Mutex as AsyncMutex, OwnedMutexGuard,

0 commit comments

Comments
 (0)