Skip to content

Upgrade matrix-sdk-ui to Rust edition 2024 #5309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "matrix-sdk-ui"
description = "GUI-centric utilities on top of matrix-rust-sdk (experimental)."
version = "0.13.0"
edition = "2021"
edition = "2024"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

repository = "https://github.com/matrix-org/matrix-rust-sdk"
license = "Apache-2.0"
rust-version.workspace = true
Expand Down
14 changes: 5 additions & 9 deletions crates/matrix-sdk-ui/src/encryption_sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ use std::{pin::Pin, time::Duration};

use async_stream::stream;
use futures_core::stream::Stream;
use futures_util::{pin_mut, StreamExt};
use matrix_sdk::{sleep::sleep, Client, SlidingSync, LEASE_DURATION_MS};
use futures_util::{StreamExt, pin_mut};
use matrix_sdk::{Client, LEASE_DURATION_MS, SlidingSync, sleep::sleep};
use ruma::{api::client::sync::sync_events::v5 as http, assign};
use tokio::sync::OwnedMutexGuard;
use tracing::{debug, instrument, trace, Span};
use tracing::{Span, debug, instrument, trace};

/// Unit type representing a permit to *use* an [`EncryptionSyncService`].
///
Expand Down Expand Up @@ -66,11 +66,7 @@ pub enum WithLocking {

impl From<bool> for WithLocking {
fn from(value: bool) -> Self {
if value {
Self::Yes
} else {
Self::No
}
if value { Self::Yes } else { Self::No }
}
}

Expand Down Expand Up @@ -130,7 +126,7 @@ impl EncryptionSyncService {
// Any other error is fatal
return Err(Error::ClientError(err));
}
};
}
}

Ok(Self { client, sliding_sync, with_locking })
Expand Down
17 changes: 9 additions & 8 deletions crates/matrix-sdk-ui/src/notification_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,39 @@ use std::{
time::Duration,
};

use futures_util::{pin_mut, StreamExt as _};
use futures_util::{StreamExt as _, pin_mut};
use matrix_sdk::{
room::Room, sleep::sleep, Client, ClientBuildError, SlidingSyncList, SlidingSyncMode,
Client, ClientBuildError, SlidingSyncList, SlidingSyncMode, room::Room, sleep::sleep,
};
use matrix_sdk_base::{deserialized_responses::TimelineEvent, RoomState, StoreError};
use matrix_sdk_base::{RoomState, StoreError, deserialized_responses::TimelineEvent};
use ruma::{
EventId, OwnedEventId, OwnedRoomId, RoomId, UserId,
api::client::sync::sync_events::v5 as http,
assign,
directory::RoomTypeFilter,
events::{
AnyFullStateEventContent, AnyMessageLikeEventContent, AnyStateEvent,
AnySyncMessageLikeEvent, AnySyncTimelineEvent, FullStateEventContent, StateEventType,
TimelineEventType,
room::{
join_rules::JoinRule,
member::{MembershipState, StrippedRoomMemberEvent},
message::{Relation, SyncRoomMessageEvent},
},
AnyFullStateEventContent, AnyMessageLikeEventContent, AnyStateEvent,
AnySyncMessageLikeEvent, AnySyncTimelineEvent, FullStateEventContent, StateEventType,
TimelineEventType,
},
html::RemoveReplyFallback,
push::Action,
serde::Raw,
uint, EventId, OwnedEventId, OwnedRoomId, RoomId, UserId,
uint,
};
use thiserror::Error;
use tokio::sync::Mutex as AsyncMutex;
use tracing::{debug, info, instrument, trace, warn};

use crate::{
DEFAULT_SANITIZER_MODE,
encryption_sync_service::{EncryptionSyncPermit, EncryptionSyncService, WithLocking},
sync_service::SyncService,
DEFAULT_SANITIZER_MODE,
};

/// What kind of process setup do we have for this notification client?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{BoxedFilterFn, Filter};

/// Create a new filter that will run multiple filters. It returns `true` if at
/// least one of the filter returns `true`.
pub fn new_filter(filters: Vec<BoxedFilterFn>) -> impl Filter {
pub fn new_filter(filters: Vec<BoxedFilterFn>) -> impl Filter + use<> {
move |room| -> bool { filters.iter().any(|filter| filter(room)) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

pub use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher as _};
pub use fuzzy_matcher::{FuzzyMatcher as _, skim::SkimMatcherV2};

use super::{normalize_string, Filter};
use super::{Filter, normalize_string};

struct FuzzyMatcher {
matcher: SkimMatcherV2,
Expand Down Expand Up @@ -44,7 +44,7 @@ impl FuzzyMatcher {
///
/// Rooms are fetched from the `Client`. The pattern and the room names are
/// normalized with `normalize_string`.
pub fn new_filter(pattern: &str) -> impl Filter {
pub fn new_filter(pattern: &str) -> impl Filter + use<> {
let searcher = FuzzyMatcher::new().with_pattern(pattern);

move |room| -> bool {
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//!
//! ```rust
//! use matrix_sdk_ui::room_list_service::{
//! filters, RoomListDynamicEntriesController,
//! RoomListDynamicEntriesController, filters,
//! };
//!
//! fn configure_room_list(
Expand Down Expand Up @@ -67,7 +67,7 @@ mod unread;

pub use all::new_filter as new_filter_all;
pub use any::new_filter as new_filter_any;
pub use category::{new_filter as new_filter_category, RoomCategory};
pub use category::{RoomCategory, new_filter as new_filter_category};
pub use deduplicate_versions::new_filter as new_filter_deduplicate_versions;
pub use favourite::new_filter as new_filter_favourite;
pub use fuzzy_match_room_name::new_filter as new_filter_fuzzy_match_room_name;
Expand All @@ -84,12 +84,12 @@ pub use normalized_match_room_name::new_filter as new_filter_normalized_match_ro
pub use not::new_filter as new_filter_not;
#[cfg(test)]
use ruma::RoomId;
use unicode_normalization::{char::is_combining_mark, UnicodeNormalization};
use unicode_normalization::{UnicodeNormalization, char::is_combining_mark};
pub use unread::new_filter as new_filter_unread;
#[cfg(test)]
use wiremock::{
matchers::{header, method, path},
Mock, MockServer, ResponseTemplate,
matchers::{header, method, path},
};

/// A trait “alias” that represents a _filter_.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use tracing::error;

use super::{normalize_string, Filter};
use super::{Filter, normalize_string};

struct NormalizedMatcher {
pattern: Option<String>,
Expand Down Expand Up @@ -45,7 +45,7 @@ impl NormalizedMatcher {
///
/// Rooms are fetched from the `Client`. The pattern and the room names are
/// normalized with `normalize_string`.
pub fn new_filter(pattern: &str) -> impl Filter {
pub fn new_filter(pattern: &str) -> impl Filter + use<> {
let searcher = NormalizedMatcher::new().with_pattern(pattern);

move |room| -> bool {
Expand Down
20 changes: 10 additions & 10 deletions crates/matrix-sdk-ui/src/room_list_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ use std::{sync::Arc, time::Duration};

use async_stream::stream;
use eyeball::Subscriber;
use futures_util::{pin_mut, Stream, StreamExt};
use futures_util::{Stream, StreamExt, pin_mut};
use matrix_sdk::{
event_cache::EventCacheError, timeout::timeout, Client, Error as SlidingSyncError, Room,
SlidingSync, SlidingSyncList, SlidingSyncMode,
Client, Error as SlidingSyncError, Room, SlidingSync, SlidingSyncList, SlidingSyncMode,
event_cache::EventCacheError, timeout::timeout,
};
pub use room_list::*;
use ruma::{
api::client::sync::sync_events::v5 as http, assign, directory::RoomTypeFilter,
events::StateEventType, OwnedRoomId, RoomId, UInt,
OwnedRoomId, RoomId, UInt, api::client::sync::sync_events::v5 as http, assign,
directory::RoomTypeFilter, events::StateEventType,
};
pub use state::*;
use thiserror::Error;
Expand Down Expand Up @@ -326,7 +326,7 @@ impl RoomListService {
&self,
delay_before_showing: Duration,
delay_before_hiding: Duration,
) -> impl Stream<Item = SyncIndicator> {
) -> impl Stream<Item = SyncIndicator> + use<> {
let mut state = self.state();

stream! {
Expand Down Expand Up @@ -501,16 +501,16 @@ pub enum SyncIndicator {
mod tests {
use std::future::ready;

use futures_util::{pin_mut, StreamExt};
use futures_util::{StreamExt, pin_mut};
use matrix_sdk::{
config::RequestConfig, test_utils::client::mock_matrix_session, Client, SlidingSyncMode,
Client, SlidingSyncMode, config::RequestConfig, test_utils::client::mock_matrix_session,
};
use matrix_sdk_test::async_test;
use ruma::api::MatrixVersion;
use serde_json::json;
use wiremock::{http::Method, Match, Mock, MockServer, Request, ResponseTemplate};
use wiremock::{Match, Mock, MockServer, Request, ResponseTemplate, http::Method};

use super::{Error, RoomListService, State, ALL_ROOMS_LIST_NAME};
use super::{ALL_ROOMS_LIST_NAME, Error, RoomListService, State};

async fn new_client() -> (Client, MockServer) {
let session = mock_matrix_session();
Expand Down
6 changes: 3 additions & 3 deletions crates/matrix-sdk-ui/src/room_list_service/room_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use async_stream::stream;
use eyeball::{SharedObservable, Subscriber};
use eyeball_im::{Vector, VectorDiff};
use eyeball_im_util::vector::VectorObserverExt;
use futures_util::{pin_mut, stream, Stream, StreamExt as _};
use futures_util::{Stream, StreamExt as _, pin_mut, stream};
use matrix_sdk::{
executor::{spawn, JoinHandle},
Client, SlidingSync, SlidingSyncList,
executor::{JoinHandle, spawn},
};
use matrix_sdk_base::RoomInfoNotableUpdate;
use tokio::{
Expand All @@ -33,9 +33,9 @@ use tokio::{
use tracing::{error, trace};

use super::{
Error, Room, State,
filters::BoxedFilterFn,
sorters::{new_sorter_lexicographic, new_sorter_name, new_sorter_recency},
Error, Room, State,
};

/// A `RoomList` represents a list of rooms, from a
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/room_list_service/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::{future::ready, sync::Mutex};

use eyeball::{SharedObservable, Subscriber};
use matrix_sdk::{sliding_sync::Range, SlidingSync, SlidingSyncMode};
use matrix_sdk::{SlidingSync, SlidingSyncMode, sliding_sync::Range};
use ruma::time::{Duration, Instant};

use super::Error;
Expand Down
13 changes: 7 additions & 6 deletions crates/matrix-sdk-ui/src/sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,22 @@ use std::{sync::Arc, time::Duration};

use eyeball::{SharedObservable, Subscriber};
use futures_util::{
future::{select, Either},
pin_mut, StreamExt as _,
StreamExt as _,
future::{Either, select},
pin_mut,
};
use matrix_sdk::{
Client,
config::RequestConfig,
executor::{spawn, JoinHandle},
executor::{JoinHandle, spawn},
sleep::sleep,
Client,
};
use thiserror::Error;
use tokio::sync::{
mpsc::{Receiver, Sender},
Mutex as AsyncMutex, OwnedMutexGuard,
mpsc::{Receiver, Sender},
};
use tracing::{error, info, instrument, trace, warn, Instrument, Level, Span};
use tracing::{Instrument, Level, Span, error, info, instrument, trace, warn};

use crate::{
encryption_sync_service::{self, EncryptionSyncPermit, EncryptionSyncService, WithLocking},
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use ruma::EventId;
#[cfg(doc)]
use super::controller::TimelineMetadata;
use super::{
event_item::EventTimelineItemKind, item::TimelineUniqueId, EventTimelineItem,
ReactionsByKeyBySender, TimelineEventItemId, TimelineItem,
EventTimelineItem, ReactionsByKeyBySender, TimelineEventItemId, TimelineItem,
event_item::EventTimelineItemKind, item::TimelineUniqueId,
};

pub(super) struct EventTimelineItemWithId<'a> {
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

use std::sync::Arc;

use matrix_sdk::{executor::spawn, Room};
use matrix_sdk::{Room, executor::spawn};
use matrix_sdk_base::{SendOutsideWasm, SyncOutsideWasm};
use ruma::{events::AnySyncTimelineEvent, RoomVersionId};
use tracing::{info_span, Instrument, Span};
use ruma::{RoomVersionId, events::AnySyncTimelineEvent};
use tracing::{Instrument, Span, info_span};

use super::{
controller::{TimelineController, TimelineSettings},
DateDividerMode, Error, Timeline, TimelineDropHandle, TimelineFocus,
controller::{TimelineController, TimelineSettings},
};
use crate::{
timeline::{
Expand Down
12 changes: 4 additions & 8 deletions crates/matrix-sdk-ui/src/timeline/controller/aggregations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ use std::{borrow::Cow, collections::HashMap, sync::Arc};
use as_variant::as_variant;
use matrix_sdk::deserialized_responses::EncryptionInfo;
use ruma::{
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedTransactionId, OwnedUserId, RoomVersionId,
events::{
AnySyncTimelineEvent,
poll::unstable_start::NewUnstablePollStartEventContentWithoutRelation,
relation::Replacement, room::message::RoomMessageEventContentWithoutRelation,
AnySyncTimelineEvent,
},
serde::Raw,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedTransactionId, OwnedUserId, RoomVersionId,
};
use tracing::{info, trace, warn};

use super::{rfind_event_by_item_id, ObservableItemsTransaction};
use super::{ObservableItemsTransaction, rfind_event_by_item_id};
use crate::timeline::{
EventTimelineItem, MsgLikeContent, MsgLikeKind, PollState, ReactionInfo, ReactionStatus,
TimelineEventItemId, TimelineItem, TimelineItemContent,
Expand Down Expand Up @@ -642,11 +642,7 @@ fn resolve_edits(
}
}

if let Some(edit) = best_edit {
edit_item(event, edit)
} else {
false
}
if let Some(edit) = best_edit { edit_item(event, edit) } else { false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ending a function in if let feels super strange to me, I think I liked the previous version better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same, but formatted differently, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just one lined.

}

/// Apply the selected edit to the given EventTimelineItem.
Expand Down
Loading
Loading