Skip to content

Commit f9735c7

Browse files
committed
chore(base): rustfmt 2024 edition
1 parent 15e6b81 commit f9735c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+526
-471
lines changed

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,34 @@ use eyeball_im::{Vector, VectorDiff};
2626
use futures_util::Stream;
2727
#[cfg(feature = "e2e-encryption")]
2828
use matrix_sdk_crypto::{
29-
store::DynCryptoStore, types::requests::ToDeviceRequest, CollectStrategy, DecryptionSettings,
30-
EncryptionSettings, OlmError, OlmMachine, TrustRequirement,
29+
CollectStrategy, DecryptionSettings, EncryptionSettings, OlmError, OlmMachine,
30+
TrustRequirement, store::DynCryptoStore, types::requests::ToDeviceRequest,
3131
};
32-
#[cfg(feature = "e2e-encryption")]
33-
use ruma::events::room::{history_visibility::HistoryVisibility, member::MembershipState};
3432
#[cfg(doc)]
3533
use ruma::DeviceId;
34+
#[cfg(feature = "e2e-encryption")]
35+
use ruma::events::room::{history_visibility::HistoryVisibility, member::MembershipState};
3636
use ruma::{
37+
MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedUserId, RoomId, UserId,
3738
api::client::{self as api, sync::sync_events::v5},
3839
events::{
40+
StateEvent, StateEventType,
3941
ignored_user_list::IgnoredUserListEventContent,
4042
push_rules::{PushRulesEvent, PushRulesEventContent},
4143
room::member::SyncRoomMemberEvent,
42-
StateEvent, StateEventType,
4344
},
4445
push::Ruleset,
4546
time::Instant,
46-
MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedUserId, RoomId, UserId,
4747
};
48-
use tokio::sync::{broadcast, Mutex};
48+
use tokio::sync::{Mutex, broadcast};
4949
#[cfg(feature = "e2e-encryption")]
5050
use tokio::sync::{RwLock, RwLockReadGuard};
51-
use tracing::{debug, enabled, info, instrument, warn, Level};
51+
use tracing::{Level, debug, enabled, info, instrument, warn};
5252

5353
#[cfg(feature = "e2e-encryption")]
5454
use crate::RoomMemberships;
5555
use crate::{
56+
InviteAcceptanceDetails, RoomStateFilter, SessionMeta,
5657
deserialized_responses::DisplayName,
5758
error::{Error, Result},
5859
event_cache::store::EventCacheStoreLock,
@@ -61,12 +62,11 @@ use crate::{
6162
Room, RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomMembersUpdate, RoomState,
6263
},
6364
store::{
64-
ambiguity_map::AmbiguityCache, BaseStateStore, DynStateStore, MemoryStore,
65-
Result as StoreResult, RoomLoadSettings, StateChanges, StateStoreDataKey,
66-
StateStoreDataValue, StateStoreExt, StoreConfig,
65+
BaseStateStore, DynStateStore, MemoryStore, Result as StoreResult, RoomLoadSettings,
66+
StateChanges, StateStoreDataKey, StateStoreDataValue, StateStoreExt, StoreConfig,
67+
ambiguity_map::AmbiguityCache,
6768
},
6869
sync::{RoomUpdates, SyncResponse},
69-
InviteAcceptanceDetails, RoomStateFilter, SessionMeta,
7070
};
7171

7272
/// A no (network) IO client implementation.
@@ -76,7 +76,7 @@ use crate::{
7676
/// rather through `matrix_sdk::Client`.
7777
///
7878
/// ```rust
79-
/// use matrix_sdk_base::{store::StoreConfig, BaseClient, ThreadingSupport};
79+
/// use matrix_sdk_base::{BaseClient, ThreadingSupport, store::StoreConfig};
8080
///
8181
/// let client = BaseClient::new(
8282
/// StoreConfig::new("cross-process-holder-name".to_owned()),
@@ -273,7 +273,9 @@ impl BaseClient {
273273

274274
/// Get a stream of all the rooms changes, in addition to the existing
275275
/// rooms.
276-
pub fn rooms_stream(&self) -> (Vector<Room>, impl Stream<Item = Vec<VectorDiff<Room>>> + use<>) {
276+
pub fn rooms_stream(
277+
&self,
278+
) -> (Vector<Room>, impl Stream<Item = Vec<VectorDiff<Room>>> + use<>) {
277279
self.state_store.rooms_stream()
278280
}
279281

@@ -1156,13 +1158,13 @@ mod tests {
11561158
use assert_matches2::{assert_let, assert_matches};
11571159
use futures_util::FutureExt as _;
11581160
use matrix_sdk_test::{
1159-
async_test, event_factory::EventFactory, ruma_response_from_json, InvitedRoomBuilder,
1160-
LeftRoomBuilder, StateTestEvent, StrippedStateTestEvent, SyncResponseBuilder, BOB,
1161+
BOB, InvitedRoomBuilder, LeftRoomBuilder, StateTestEvent, StrippedStateTestEvent,
1162+
SyncResponseBuilder, async_test, event_factory::EventFactory, ruma_response_from_json,
11611163
};
11621164
use ruma::{
11631165
api::client::{self as api, sync::sync_events::v5},
11641166
event_id,
1165-
events::{room::member::MembershipState, StateEventType},
1167+
events::{StateEventType, room::member::MembershipState},
11661168
room_id,
11671169
serde::Raw,
11681170
user_id,
@@ -1171,10 +1173,10 @@ mod tests {
11711173

11721174
use super::{BaseClient, RequestedRequiredStates};
11731175
use crate::{
1176+
RoomDisplayName, RoomState, SessionMeta,
11741177
client::ThreadingSupport,
11751178
store::{RoomLoadSettings, StateStoreExt, StoreConfig},
11761179
test_utils::logged_in_base_client,
1177-
RoomDisplayName, RoomState, SessionMeta,
11781180
};
11791181

11801182
#[test]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ pub use matrix_sdk_common::deserialized_responses::*;
2020
use once_cell::sync::Lazy;
2121
use regex::Regex;
2222
use ruma::{
23+
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, UInt, UserId,
2324
events::{
25+
AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType,
26+
PossiblyRedactedStateEventContent, RedactContent, RedactedStateEventContent,
27+
StateEventContent, StaticStateEventContent, StrippedStateEvent, SyncStateEvent,
2428
room::{
2529
member::{MembershipState, RoomMemberEvent, RoomMemberEventContent},
2630
power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
2731
},
28-
AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType,
29-
PossiblyRedactedStateEventContent, RedactContent, RedactedStateEventContent,
30-
StateEventContent, StaticStateEventContent, StrippedStateEvent, SyncStateEvent,
3132
},
3233
serde::Raw,
33-
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, UInt, UserId,
3434
};
3535
use serde::Serialize;
3636
use unicode_normalization::UnicodeNormalization;

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

Lines changed: 76 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,26 @@ use matrix_sdk_common::{
2323
VerificationState,
2424
},
2525
linked_chunk::{
26-
lazy_loader, ChunkContent, ChunkIdentifier as CId, LinkedChunkId, Position, Update,
26+
ChunkContent, ChunkIdentifier as CId, LinkedChunkId, Position, Update, lazy_loader,
2727
},
2828
};
29-
use matrix_sdk_test::{event_factory::EventFactory, ALICE, DEFAULT_TEST_ROOM_ID};
29+
use matrix_sdk_test::{ALICE, DEFAULT_TEST_ROOM_ID, event_factory::EventFactory};
3030
use ruma::{
31+
EventId, RoomId,
3132
api::client::media::get_content_thumbnail::v3::Method,
3233
event_id,
3334
events::{
3435
relation::RelationType,
35-
room::{message::RoomMessageEventContentWithoutRelation, MediaSource},
36+
room::{MediaSource, message::RoomMessageEventContentWithoutRelation},
3637
},
3738
mxc_uri,
3839
push::Action,
39-
room_id, uint, EventId, RoomId,
40+
room_id, uint,
4041
};
4142

42-
use super::{media::IgnoreMediaRetentionPolicy, DynEventCacheStore};
43+
use super::{DynEventCacheStore, media::IgnoreMediaRetentionPolicy};
4344
use crate::{
44-
event_cache::{store::DEFAULT_CHUNK_CAPACITY, Gap},
45+
event_cache::{Gap, store::DEFAULT_CHUNK_CAPACITY},
4546
media::{MediaFormat, MediaRequestParameters, MediaThumbnailSettings},
4647
};
4748

@@ -760,31 +761,39 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
760761
.unwrap();
761762

762763
// Sanity check: both linked chunks can be reloaded.
763-
assert!(lazy_loader::from_all_chunks::<3, _, _>(
764-
self.load_all_chunks(linked_chunk_id0).await.unwrap()
765-
)
766-
.unwrap()
767-
.is_some());
768-
assert!(lazy_loader::from_all_chunks::<3, _, _>(
769-
self.load_all_chunks(linked_chunk_id1).await.unwrap()
770-
)
771-
.unwrap()
772-
.is_some());
764+
assert!(
765+
lazy_loader::from_all_chunks::<3, _, _>(
766+
self.load_all_chunks(linked_chunk_id0).await.unwrap()
767+
)
768+
.unwrap()
769+
.is_some()
770+
);
771+
assert!(
772+
lazy_loader::from_all_chunks::<3, _, _>(
773+
self.load_all_chunks(linked_chunk_id1).await.unwrap()
774+
)
775+
.unwrap()
776+
.is_some()
777+
);
773778

774779
// Clear the chunks.
775780
self.clear_all_linked_chunks().await.unwrap();
776781

777782
// Both rooms now have no linked chunk.
778-
assert!(lazy_loader::from_all_chunks::<3, _, _>(
779-
self.load_all_chunks(linked_chunk_id0).await.unwrap()
780-
)
781-
.unwrap()
782-
.is_none());
783-
assert!(lazy_loader::from_all_chunks::<3, _, _>(
784-
self.load_all_chunks(linked_chunk_id1).await.unwrap()
785-
)
786-
.unwrap()
787-
.is_none());
783+
assert!(
784+
lazy_loader::from_all_chunks::<3, _, _>(
785+
self.load_all_chunks(linked_chunk_id0).await.unwrap()
786+
)
787+
.unwrap()
788+
.is_none()
789+
);
790+
assert!(
791+
lazy_loader::from_all_chunks::<3, _, _>(
792+
self.load_all_chunks(linked_chunk_id1).await.unwrap()
793+
)
794+
.unwrap()
795+
.is_none()
796+
);
788797
}
789798

790799
async fn test_remove_room(&self) {
@@ -970,19 +979,21 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
970979
assert_eq!(event.event_id(), event_comte.event_id());
971980

972981
// Now let's try to find an event that exists, but not in the expected room.
973-
assert!(self
974-
.find_event(room_id, event_gruyere.event_id().unwrap().as_ref())
975-
.await
976-
.expect("failed to query for finding an event")
977-
.is_none());
982+
assert!(
983+
self.find_event(room_id, event_gruyere.event_id().unwrap().as_ref())
984+
.await
985+
.expect("failed to query for finding an event")
986+
.is_none()
987+
);
978988

979989
// Clearing the rooms also clears the event's storage.
980990
self.clear_all_linked_chunks().await.expect("failed to clear all rooms chunks");
981-
assert!(self
982-
.find_event(room_id, event_comte.event_id().unwrap().as_ref())
983-
.await
984-
.expect("failed to query for finding an event")
985-
.is_none());
991+
assert!(
992+
self.find_event(room_id, event_comte.event_id().unwrap().as_ref())
993+
.await
994+
.expect("failed to query for finding an event")
995+
.is_none()
996+
);
986997
}
987998

988999
async fn test_find_event_relations(&self) {
@@ -1029,12 +1040,16 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
10291040
let relations = self.find_event_relations(room_id, eid1, None).await.unwrap();
10301041
assert_eq!(relations.len(), 2);
10311042
// The position is `None` for items outside the linked chunk.
1032-
assert!(relations
1033-
.iter()
1034-
.any(|(ev, pos)| ev.event_id().as_deref() == Some(edit_eid1) && pos.is_none()));
1035-
assert!(relations
1036-
.iter()
1037-
.any(|(ev, pos)| ev.event_id().as_deref() == Some(reaction_eid1) && pos.is_none()));
1043+
assert!(
1044+
relations
1045+
.iter()
1046+
.any(|(ev, pos)| ev.event_id().as_deref() == Some(edit_eid1) && pos.is_none())
1047+
);
1048+
assert!(
1049+
relations
1050+
.iter()
1051+
.any(|(ev, pos)| ev.event_id().as_deref() == Some(reaction_eid1) && pos.is_none())
1052+
);
10381053

10391054
// Finding relations with a filter only returns a subset.
10401055
let relations = self
@@ -1088,9 +1103,11 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
10881103
}));
10891104

10901105
// But it's still not set for the other related events.
1091-
assert!(relations
1092-
.iter()
1093-
.any(|(ev, pos)| ev.event_id().as_deref() == Some(edit_eid1) && pos.is_none()));
1106+
assert!(
1107+
relations
1108+
.iter()
1109+
.any(|(ev, pos)| ev.event_id().as_deref() == Some(edit_eid1) && pos.is_none())
1110+
);
10941111
}
10951112

10961113
async fn test_save_event(&self) {
@@ -1123,16 +1140,18 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
11231140
assert_eq!(event.event_id(), event_gruyere.event_id());
11241141

11251142
// But they won't be returned when searching in the wrong room.
1126-
assert!(self
1127-
.find_event(another_room_id, event_comte.event_id().unwrap().as_ref())
1128-
.await
1129-
.expect("failed to query for finding an event")
1130-
.is_none());
1131-
assert!(self
1132-
.find_event(room_id, event_gruyere.event_id().unwrap().as_ref())
1133-
.await
1134-
.expect("failed to query for finding an event")
1135-
.is_none());
1143+
assert!(
1144+
self.find_event(another_room_id, event_comte.event_id().unwrap().as_ref())
1145+
.await
1146+
.expect("failed to query for finding an event")
1147+
.is_none()
1148+
);
1149+
assert!(
1150+
self.find_event(room_id, event_gruyere.event_id().unwrap().as_ref())
1151+
.await
1152+
.expect("failed to query for finding an event")
1153+
.is_none()
1154+
);
11361155
}
11371156
}
11381157

@@ -1155,8 +1174,8 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
11551174
/// mod tests {
11561175
/// use super::{EventCacheStore, EventCacheStoreResult, MyStore};
11571176
///
1158-
/// async fn get_event_cache_store(
1159-
/// ) -> EventCacheStoreResult<impl EventCacheStore> {
1177+
/// async fn get_event_cache_store()
1178+
/// -> EventCacheStoreResult<impl EventCacheStore> {
11601179
/// Ok(MyStore::new())
11611180
/// }
11621181
///

crates/matrix-sdk-base/src/event_cache/store/media/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ruma::{
2222
};
2323

2424
use super::{
25-
media_service::IgnoreMediaRetentionPolicy, EventCacheStoreMedia, MediaRetentionPolicy,
25+
EventCacheStoreMedia, MediaRetentionPolicy, media_service::IgnoreMediaRetentionPolicy,
2626
};
2727
use crate::media::{MediaFormat, MediaRequestParameters};
2828

crates/matrix-sdk-base/src/event_cache/store/media/media_service.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use std::{fmt, sync::Arc};
1616

1717
use async_trait::async_trait;
1818
use matrix_sdk_common::{
19-
executor::{spawn, JoinHandle},
20-
locks::Mutex,
2119
AsyncTraitDeps, SendOutsideWasm, SyncOutsideWasm,
20+
executor::{JoinHandle, spawn},
21+
locks::Mutex,
2222
};
23-
use ruma::{time::SystemTime, MxcUri};
23+
use ruma::{MxcUri, time::SystemTime};
2424
use tokio::sync::Mutex as AsyncMutex;
2525
use tracing::error;
2626

@@ -538,15 +538,15 @@ mod tests {
538538
use matrix_sdk_common::locks::Mutex;
539539
use matrix_sdk_test::async_test;
540540
use ruma::{
541+
MxcUri, OwnedMxcUri,
541542
events::room::MediaSource,
542543
mxc_uri,
543544
time::{Duration, SystemTime},
544-
MxcUri, OwnedMxcUri,
545545
};
546546

547547
use super::{EventCacheStoreMedia, IgnoreMediaRetentionPolicy, MediaService, TimeProvider};
548548
use crate::{
549-
event_cache::store::{media::MediaRetentionPolicy, EventCacheStoreError},
549+
event_cache::store::{EventCacheStoreError, media::MediaRetentionPolicy},
550550
media::{MediaFormat, MediaRequestParameters, UniqueKey},
551551
};
552552

0 commit comments

Comments
 (0)