diff --git a/rustfmt.toml b/rustfmt.toml index c7d24c00..606d9c82 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -style_edition = "2021" +style_edition = "2024" condense_wildcard_suffixes = true error_on_line_overflow = true diff --git a/src/api/appservice_server.rs b/src/api/appservice_server.rs index 117d1914..e5f4d0da 100644 --- a/src/api/appservice_server.rs +++ b/src/api/appservice_server.rs @@ -2,12 +2,12 @@ use std::{fmt::Debug, mem, time::Duration}; use bytes::BytesMut; use ruma::api::{ - appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, - SendAccessToken, + IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken, + appservice::Registration, }; use tracing::warn; -use crate::{services, utils, Error, Result}; +use crate::{Error, Result, services, utils}; /// Sends a request to an appservice /// diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index d660c6ba..29410d39 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -1,25 +1,26 @@ use register::RegistrationKind; use ruma::{ + UserId, api::client::{ account::{ - change_password, deactivate, get_3pids, get_username_availability, + ThirdPartyIdRemovalStatus, change_password, deactivate, get_3pids, + get_username_availability, register::{self, LoginType}, request_3pid_management_token_via_email, request_3pid_management_token_via_msisdn, whoami, - ThirdPartyIdRemovalStatus, }, error::ErrorKind, uiaa::{AuthFlow, AuthType, UiaaInfo}, }, events::{ - room::message::RoomMessageEventContent, GlobalAccountDataEventType, + GlobalAccountDataEventType, room::message::RoomMessageEventContent, }, - push, UserId, + push, }; use tracing::{info, warn}; use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; -use crate::{api::client_server, services, utils, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, api::client_server, services, utils}; const RANDOM_USER_ID_LENGTH: usize = 10; diff --git a/src/api/client_server/alias.rs b/src/api/client_server/alias.rs index b2fbcf65..92cc8ca4 100644 --- a/src/api/client_server/alias.rs +++ b/src/api/client_server/alias.rs @@ -1,5 +1,6 @@ use rand::seq::SliceRandom; use ruma::{ + OwnedRoomAliasId, api::{ appservice::query::query_room_alias, client::{ @@ -8,10 +9,9 @@ use ruma::{ }, federation, }, - OwnedRoomAliasId, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `PUT /_matrix/client/r0/directory/room/{roomAlias}` /// diff --git a/src/api/client_server/backup.rs b/src/api/client_server/backup.rs index cc0a0640..6172409f 100644 --- a/src/api/client_server/backup.rs +++ b/src/api/client_server/backup.rs @@ -9,7 +9,7 @@ use ruma::api::client::{ error::ErrorKind, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `POST /_matrix/client/r0/room_keys/version` /// diff --git a/src/api/client_server/capabilities.rs b/src/api/client_server/capabilities.rs index 515ebfc1..5ea65e94 100644 --- a/src/api/client_server/capabilities.rs +++ b/src/api/client_server/capabilities.rs @@ -4,7 +4,7 @@ use ruma::api::client::discovery::get_capabilities::{ self, Capabilities, RoomVersionStability, RoomVersionsCapability, }; -use crate::{services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, services}; /// # `GET /_matrix/client/r0/capabilities` /// diff --git a/src/api/client_server/config.rs b/src/api/client_server/config.rs index 8d9a0a84..eae2215e 100644 --- a/src/api/client_server/config.rs +++ b/src/api/client_server/config.rs @@ -14,7 +14,7 @@ use ruma::{ use serde::Deserialize; use serde_json::{json, value::RawValue as RawJsonValue}; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}` /// diff --git a/src/api/client_server/context.rs b/src/api/client_server/context.rs index ba803454..c2a3db69 100644 --- a/src/api/client_server/context.rs +++ b/src/api/client_server/context.rs @@ -9,7 +9,7 @@ use ruma::{ }; use tracing::error; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `GET /_matrix/client/r0/rooms/{roomId}/context` /// diff --git a/src/api/client_server/device.rs b/src/api/client_server/device.rs index f94cae6e..ed5a2a8c 100644 --- a/src/api/client_server/device.rs +++ b/src/api/client_server/device.rs @@ -8,7 +8,7 @@ use ruma::api::client::{ }; use super::SESSION_ID_LENGTH; -use crate::{services, utils, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services, utils}; /// # `GET /_matrix/client/r0/devices` /// diff --git a/src/api/client_server/directory.rs b/src/api/client_server/directory.rs index ed95e034..98a0548a 100644 --- a/src/api/client_server/directory.rs +++ b/src/api/client_server/directory.rs @@ -1,4 +1,5 @@ use ruma::{ + ServerName, UInt, api::{ client::{ directory::{ @@ -12,6 +13,7 @@ use ruma::{ }, directory::{Filter, PublicRoomJoinRule, PublicRoomsChunk, RoomNetwork}, events::{ + StateEventType, room::{ avatar::RoomAvatarEventContent, canonical_alias::RoomCanonicalAliasEventContent, @@ -22,14 +24,13 @@ use ruma::{ join_rules::{JoinRule, RoomJoinRulesEventContent}, topic::RoomTopicEventContent, }, - StateEventType, }, - uint, ServerName, UInt, + uint, }; use tracing::{error, info, warn}; use crate::{ - service::rooms::state::ExtractType, services, Ar, Error, Ra, Result, + Ar, Error, Ra, Result, service::rooms::state::ExtractType, services, }; /// # `POST /_matrix/client/r0/publicRooms` @@ -185,7 +186,7 @@ pub(crate) async fn get_public_rooms_filtered_helper( return Err(Error::BadRequest( ErrorKind::InvalidParam, "Invalid `since` token", - )) + )); } }; diff --git a/src/api/client_server/filter.rs b/src/api/client_server/filter.rs index e99f8b17..562e9371 100644 --- a/src/api/client_server/filter.rs +++ b/src/api/client_server/filter.rs @@ -3,7 +3,7 @@ use ruma::api::client::{ filter::{create_filter, get_filter}, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}` /// diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index d2e3006f..987e9b68 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -1,10 +1,12 @@ use std::{ - collections::{hash_map, BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet, hash_map}, time::{Duration, Instant}, }; -use futures_util::{stream::FuturesUnordered, StreamExt}; +use futures_util::{StreamExt, stream::FuturesUnordered}; use ruma::{ + OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId, + ServerName, UserId, api::{ client::{ error::ErrorKind, @@ -17,14 +19,12 @@ use ruma::{ federation, }, serde::Raw, - OneTimeKeyAlgorithm, OwnedDeviceId, OwnedServerName, OwnedUserId, - ServerName, UserId, }; use serde_json::json; use tracing::debug; use super::SESSION_ID_LENGTH; -use crate::{services, utils, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services, utils}; /// # `POST /_matrix/client/r0/keys/upload` /// diff --git a/src/api/client_server/media.rs b/src/api/client_server/media.rs index ca9dda86..c5bbbe7f 100644 --- a/src/api/client_server/media.rs +++ b/src/api/client_server/media.rs @@ -2,10 +2,10 @@ use std::time::Duration; use axum::response::IntoResponse; use http::{ - header::{CONTENT_DISPOSITION, CONTENT_SECURITY_POLICY, CONTENT_TYPE}, HeaderName, HeaderValue, Method, + header::{CONTENT_DISPOSITION, CONTENT_SECURITY_POLICY, CONTENT_TYPE}, }; -use phf::{phf_set, Set}; +use phf::{Set, phf_set}; use ruma::{ api::{ client::{ @@ -20,10 +20,10 @@ use ruma::{ use tracing::{debug, error, info, warn}; use crate::{ + Ar, Error, Ra, Result, service::media::FileMeta, services, utils::{self, MxcData}, - Ar, Error, Ra, Result, }; const MXC_LENGTH: usize = 32; diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 7d6c9cdb..79bbba36 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -1,46 +1,48 @@ use std::{ - collections::{hash_map::Entry, BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet, hash_map::Entry}, sync::Arc, time::{Duration, Instant}, }; use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, + MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName, + OwnedUserId, RoomId, RoomVersionId, UserId, api::{ client::{ error::ErrorKind, membership::{ - ban_user, forget_room, get_member_events, invite_user, - join_room_by_id, join_room_by_id_or_alias, joined_members, - joined_rooms, kick_user, leave_room, unban_user, - ThirdPartySigned, + ThirdPartySigned, ban_user, forget_room, get_member_events, + invite_user, join_room_by_id, join_room_by_id_or_alias, + joined_members, joined_rooms, kick_user, leave_room, + unban_user, }, }, federation::{self, membership::create_invite}, }, canonical_json::to_canonical_value, events::{ + StateEventType, TimelineEventType, room::{ join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent}, member::{MembershipState, RoomMemberEventContent}, }, - StateEventType, TimelineEventType, }, - state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, - MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName, - OwnedUserId, RoomId, RoomVersionId, UserId, + state_res, }; -use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; +use serde_json::value::{RawValue as RawJsonValue, to_raw_value}; use tokio::sync::RwLock; use tracing::{debug, error, info, warn}; use super::get_alias_helper; use crate::{ + Ar, Error, PduEvent, Ra, Result, service::{ globals::SigningKeys, - pdu::{gen_event_id_canonical_json, PduBuilder}, + pdu::{PduBuilder, gen_event_id_canonical_json}, rooms::state::ExtractVersion, }, - services, utils, Ar, Error, PduEvent, Ra, Result, + services, utils, }; /// # `POST /_matrix/client/r0/rooms/{roomId}/join` @@ -625,7 +627,7 @@ async fn join_room_by_id_helper( Ok(_event_id) => { return Ok(join_room_by_id::v3::Response::new( room_id.to_owned(), - )) + )); } Err(e) => e, }; @@ -658,7 +660,7 @@ async fn join_room_by_id_helper( _ => { return Err(Error::BadServerResponse( "Room version is not supported", - )) + )); } }; let mut join_event_stub: CanonicalJsonObject = serde_json::from_str( @@ -810,7 +812,7 @@ async fn join_room_by_id_helper( _ => { return Err(Error::BadServerResponse( "Room version is not supported", - )) + )); } }; @@ -1638,7 +1640,7 @@ async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> { _ => { return Err(Error::BadServerResponse( "Room version is not supported", - )) + )); } }; diff --git a/src/api/client_server/message.rs b/src/api/client_server/message.rs index df723d07..497ae76d 100644 --- a/src/api/client_server/message.rs +++ b/src/api/client_server/message.rs @@ -10,8 +10,9 @@ use ruma::{ }; use crate::{ + Ar, Error, Ra, Result, service::{pdu::PduBuilder, rooms::timeline::PduCount}, - services, utils, Ar, Error, Ra, Result, + services, utils, }; /// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}` diff --git a/src/api/client_server/profile.rs b/src/api/client_server/profile.rs index 8a84f743..0d3ffaf7 100644 --- a/src/api/client_server/profile.rs +++ b/src/api/client_server/profile.rs @@ -10,13 +10,13 @@ use ruma::{ federation::{self, query::get_profile_information::v1::ProfileField}, }, events::{ - room::member::RoomMemberEventContent, StateEventType, TimelineEventType, + StateEventType, TimelineEventType, room::member::RoomMemberEventContent, }, }; use serde_json::value::to_raw_value; use tracing::warn; -use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, service::pdu::PduBuilder, services}; /// # `PUT /_matrix/client/r0/profile/{userId}/displayname` /// diff --git a/src/api/client_server/push.rs b/src/api/client_server/push.rs index 9d2b5956..c6b0612b 100644 --- a/src/api/client_server/push.rs +++ b/src/api/client_server/push.rs @@ -7,11 +7,11 @@ use ruma::{ set_pushrule_actions, set_pushrule_enabled, }, }, - events::{push_rules::PushRulesEvent, GlobalAccountDataEventType}, + events::{GlobalAccountDataEventType, push_rules::PushRulesEvent}, push::{AnyPushRuleRef, InsertPushRuleError, RemovePushRuleError}, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `GET /_matrix/client/r0/pushrules` /// diff --git a/src/api/client_server/read_marker.rs b/src/api/client_server/read_marker.rs index c30a4cb8..210535a8 100644 --- a/src/api/client_server/read_marker.rs +++ b/src/api/client_server/read_marker.rs @@ -1,18 +1,18 @@ use std::collections::BTreeMap; use ruma::{ + MilliSecondsSinceUnixEpoch, api::client::{ error::ErrorKind, read_marker::set_read_marker, receipt::create_receipt, }, events::{ - receipt::{ReceiptThread, ReceiptType}, RoomAccountDataEventType, + receipt::{ReceiptThread, ReceiptType}, }, - MilliSecondsSinceUnixEpoch, }; use crate::{ - service::rooms::timeline::PduCount, services, Ar, Error, Ra, Result, + Ar, Error, Ra, Result, service::rooms::timeline::PduCount, services, }; /// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers` @@ -58,7 +58,7 @@ pub(crate) async fn set_read_marker_route( return Err(Error::BadRequest( ErrorKind::InvalidParam, "Read receipt is in backfilled timeline", - )) + )); } PduCount::Normal(c) => c, }; @@ -174,7 +174,7 @@ pub(crate) async fn create_receipt_route( return Err(Error::BadRequest( ErrorKind::InvalidParam, "Read receipt is in backfilled timeline", - )) + )); } PduCount::Normal(c) => c, }; diff --git a/src/api/client_server/redact.rs b/src/api/client_server/redact.rs index 46af6d8c..7b176be8 100644 --- a/src/api/client_server/redact.rs +++ b/src/api/client_server/redact.rs @@ -1,10 +1,10 @@ use ruma::{ api::client::redact::redact_event, - events::{room::redaction::RoomRedactionEventContent, TimelineEventType}, + events::{TimelineEventType, room::redaction::RoomRedactionEventContent}, }; use serde_json::value::to_raw_value; -use crate::{service::pdu::PduBuilder, services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, service::pdu::PduBuilder, services}; /// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}` /// diff --git a/src/api/client_server/relations.rs b/src/api/client_server/relations.rs index c40224c9..75e69404 100644 --- a/src/api/client_server/relations.rs +++ b/src/api/client_server/relations.rs @@ -6,7 +6,7 @@ use ruma::{ uint, }; -use crate::{service::rooms::timeline::PduCount, services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, service::rooms::timeline::PduCount, services}; /// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}` pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route( diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index edf18057..d1a1ccf6 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -4,7 +4,7 @@ use ruma::{ int, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}` /// diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index ebb5a26b..d540a282 100644 --- a/src/api/client_server/room.rs +++ b/src/api/client_server/room.rs @@ -1,11 +1,13 @@ use std::{cmp::max, collections::BTreeMap}; use ruma::{ + CanonicalJsonObject, OwnedRoomAliasId, RoomAliasId, RoomId, api::client::{ error::ErrorKind, room::{self, aliases, create_room, get_room_event, upgrade_room}, }, events::{ + StateEventType, TimelineEventType, room::{ canonical_alias::RoomCanonicalAliasEventContent, create::RoomCreateEventContent, @@ -20,18 +22,16 @@ use ruma::{ tombstone::RoomTombstoneEventContent, topic::RoomTopicEventContent, }, - StateEventType, TimelineEventType, }, int, serde::JsonObject, - CanonicalJsonObject, OwnedRoomAliasId, RoomAliasId, RoomId, }; use serde_json::{json, value::to_raw_value}; use tracing::{info, warn}; use crate::{ - api::client_server::invite_helper, service::pdu::PduBuilder, services, - utils::room_version::RoomVersion, Ar, Error, Ra, Result, + Ar, Error, Ra, Result, api::client_server::invite_helper, + service::pdu::PduBuilder, services, utils::room_version::RoomVersion, }; /// # `POST /_matrix/client/r0/createRoom` diff --git a/src/api/client_server/search.rs b/src/api/client_server/search.rs index cd36a13b..5288c3b1 100644 --- a/src/api/client_server/search.rs +++ b/src/api/client_server/search.rs @@ -1,6 +1,7 @@ use std::collections::BTreeMap; use ruma::{ + UInt, api::client::{ error::ErrorKind, search::search_events::{ @@ -11,10 +12,10 @@ use ruma::{ }, }, }, - uint, UInt, + uint, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `POST /_matrix/client/r0/search` /// @@ -73,7 +74,7 @@ pub(crate) async fn search_events_route( return Err(Error::BadRequest( ErrorKind::InvalidParam, "Invalid next_batch token.", - )) + )); } // Default to the start None => 0, diff --git a/src/api/client_server/session.rs b/src/api/client_server/session.rs index 228ab4d3..8248fb72 100644 --- a/src/api/client_server/session.rs +++ b/src/api/client_server/session.rs @@ -1,4 +1,5 @@ use ruma::{ + UserId, api::client::{ error::ErrorKind, session::{ @@ -10,13 +11,12 @@ use ruma::{ }, uiaa::UserIdentifier, }, - UserId, }; use serde::Deserialize; use tracing::{info, warn}; use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH}; -use crate::{services, utils, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services, utils}; #[derive(Debug, Deserialize)] struct Claims { diff --git a/src/api/client_server/space.rs b/src/api/client_server/space.rs index 930814e8..9f451780 100644 --- a/src/api/client_server/space.rs +++ b/src/api/client_server/space.rs @@ -1,6 +1,6 @@ use ruma::{api::client::space::get_hierarchy, uint}; -use crate::{services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, services}; /// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy` /// diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs index 2e6f3b13..a0ced7c0 100644 --- a/src/api/client_server/state.rs +++ b/src/api/client_server/state.rs @@ -1,21 +1,21 @@ use std::{collections::HashSet, sync::Arc}; use ruma::{ + EventId, RoomAliasId, RoomId, UserId, api::client::{ error::ErrorKind, state::{get_state_events, get_state_events_for_key, send_state_event}, }, events::{ - room::canonical_alias::RoomCanonicalAliasEventContent, AnyStateEventContent, StateEventType, + room::canonical_alias::RoomCanonicalAliasEventContent, }, serde::Raw, - EventId, RoomAliasId, RoomId, UserId, }; use serde::Deserialize; use tracing::warn; -use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, service::pdu::PduBuilder, services}; /// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}` /// diff --git a/src/api/client_server/sync.rs b/src/api/client_server/sync.rs index 2a17aa17..79a306b7 100644 --- a/src/api/client_server/sync.rs +++ b/src/api/client_server/sync.rs @@ -1,8 +1,8 @@ -use ruma::{events::StateEventType, RoomId, UserId}; +use ruma::{RoomId, UserId, events::StateEventType}; use tracing::error; use crate::{ - service::rooms::timeline::PduCount, services, Error, PduEvent, Result, + Error, PduEvent, Result, service::rooms::timeline::PduCount, services, }; pub(crate) mod msc3575; diff --git a/src/api/client_server/sync/msc3575.rs b/src/api/client_server/sync/msc3575.rs index f345b11d..b5435fb8 100644 --- a/src/api/client_server/sync/msc3575.rs +++ b/src/api/client_server/sync/msc3575.rs @@ -9,23 +9,24 @@ use std::{ }; use ruma::{ + JsOption, UInt, UserId, api::client::{ sync::sync_events::{ - self, v4::SlidingOp, DeviceLists, UnreadNotificationsCount, + self, DeviceLists, UnreadNotificationsCount, v4::SlidingOp, }, uiaa::UiaaResponse, }, events::{ - room::member::{MembershipState, RoomMemberEventContent}, StateEventType, TimelineEventType, + room::member::{MembershipState, RoomMemberEventContent}, }, - uint, JsOption, UInt, UserId, + uint, }; use tracing::{debug, error}; use super::{load_timeline, share_encrypted_room}; use crate::{ - service::rooms::timeline::PduCount, services, Ar, Error, Ra, Result, + Ar, Error, Ra, Result, service::rooms::timeline::PduCount, services, }; #[allow(clippy::too_many_lines)] diff --git a/src/api/client_server/sync/v3.rs b/src/api/client_server/sync/v3.rs index 57367564..19c668ca 100644 --- a/src/api/client_server/sync/v3.rs +++ b/src/api/client_server/sync/v3.rs @@ -4,31 +4,32 @@ use std::{ }; use ruma::{ + DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, api::client::{ filter::{FilterDefinition, LazyLoadOptions}, sync::sync_events::{ - self, + self, DeviceLists, UnreadNotificationsCount, v3::{ Ephemeral, Filter, GlobalAccountData, InviteState, InvitedRoom, JoinedRoom, LeftRoom, Presence, RoomAccountData, RoomSummary, Rooms, State, Timeline, ToDevice, }, - DeviceLists, UnreadNotificationsCount, }, uiaa::UiaaResponse, }, events::{ - room::member::{MembershipState, RoomMemberEventContent}, StateEventType, TimelineEventType, + room::member::{MembershipState, RoomMemberEventContent}, }, - uint, DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, + uint, }; use tracing::{debug, error, field}; use super::{load_timeline, share_encrypted_room}; use crate::{ + Ar, Error, PduEvent, Ra, Result, service::{pdu::EventHash, rooms::timeline::PduCount}, - services, utils, Ar, Error, PduEvent, Ra, Result, + services, utils, }; struct SyncContext<'a> { diff --git a/src/api/client_server/tag.rs b/src/api/client_server/tag.rs index 17367300..80627fec 100644 --- a/src/api/client_server/tag.rs +++ b/src/api/client_server/tag.rs @@ -3,12 +3,12 @@ use std::collections::BTreeMap; use ruma::{ api::client::tag::{create_tag, delete_tag, get_tags}, events::{ - tag::{TagEvent, TagEventContent}, RoomAccountDataEventType, + tag::{TagEvent, TagEventContent}, }, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}` /// diff --git a/src/api/client_server/threads.rs b/src/api/client_server/threads.rs index cf96e234..46075ead 100644 --- a/src/api/client_server/threads.rs +++ b/src/api/client_server/threads.rs @@ -1,6 +1,6 @@ use ruma::api::client::{error::ErrorKind, threads::get_threads}; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `GET /_matrix/client/r0/rooms/{roomId}/threads` pub(crate) async fn get_threads_route( diff --git a/src/api/client_server/to_device.rs b/src/api/client_server/to_device.rs index 663908b4..2903576e 100644 --- a/src/api/client_server/to_device.rs +++ b/src/api/client_server/to_device.rs @@ -9,7 +9,7 @@ use ruma::{ to_device::DeviceIdOrAllDevices, }; -use crate::{services, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services}; /// # `PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}` /// diff --git a/src/api/client_server/typing.rs b/src/api/client_server/typing.rs index 2657b084..6262c6f7 100644 --- a/src/api/client_server/typing.rs +++ b/src/api/client_server/typing.rs @@ -1,6 +1,6 @@ use ruma::api::client::{error::ErrorKind, typing::create_typing_event}; -use crate::{services, utils, Ar, Error, Ra, Result}; +use crate::{Ar, Error, Ra, Result, services, utils}; /// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}` /// diff --git a/src/api/client_server/user_directory.rs b/src/api/client_server/user_directory.rs index 0d8912ce..a775bcdf 100644 --- a/src/api/client_server/user_directory.rs +++ b/src/api/client_server/user_directory.rs @@ -1,12 +1,12 @@ use ruma::{ api::client::user_directory::search_users, events::{ - room::join_rules::{JoinRule, RoomJoinRulesEventContent}, StateEventType, + room::join_rules::{JoinRule, RoomJoinRulesEventContent}, }, }; -use crate::{services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, services}; /// # `POST /_matrix/client/r0/user_directory/search` /// diff --git a/src/api/client_server/voip.rs b/src/api/client_server/voip.rs index f24ca81e..3699c823 100644 --- a/src/api/client_server/voip.rs +++ b/src/api/client_server/voip.rs @@ -1,11 +1,11 @@ use std::time::{Duration, SystemTime}; -use base64::{engine::general_purpose, Engine as _}; +use base64::{Engine as _, engine::general_purpose}; use hmac::{Hmac, Mac}; -use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch}; +use ruma::{SecondsSinceUnixEpoch, api::client::voip::get_turn_server_info}; use sha1::Sha1; -use crate::{services, Ar, Ra, Result}; +use crate::{Ar, Ra, Result, services}; type HmacSha1 = Hmac; diff --git a/src/api/ruma_wrapper.rs b/src/api/ruma_wrapper.rs index 91ea8d35..081d94c5 100644 --- a/src/api/ruma_wrapper.rs +++ b/src/api/ruma_wrapper.rs @@ -1,11 +1,11 @@ use std::ops::Deref; use ruma::{ - api::client::uiaa::UiaaResponse, CanonicalJsonValue, OwnedDeviceId, - OwnedServerName, OwnedUserId, + CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, + api::client::uiaa::UiaaResponse, }; -use crate::{service::appservice::RegistrationInfo, Error}; +use crate::{Error, service::appservice::RegistrationInfo}; mod axum; diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index 712386d9..6c40733e 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -1,34 +1,33 @@ use std::{collections::BTreeMap, iter::FromIterator, str}; use axum::{ - async_trait, + RequestExt, RequestPartsExt, async_trait, body::Body, extract::{FromRequest, Path}, response::{IntoResponse, Response}, - RequestExt, RequestPartsExt, }; use axum_extra::{ - headers::{authorization::Bearer, Authorization}, - typed_header::TypedHeaderRejectionReason, TypedHeader, + headers::{Authorization, authorization::Bearer}, + typed_header::TypedHeaderRejectionReason, }; use bytes::{BufMut, Bytes, BytesMut}; use http::{Request, StatusCode}; use http_body_util::BodyExt; use ruma::{ - api::{ - client::error::ErrorKind, AuthScheme, IncomingRequest, Metadata, - OutgoingResponse, - }, - server_util::authorization::XMatrix, CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId, + api::{ + AuthScheme, IncomingRequest, Metadata, OutgoingResponse, + client::error::ErrorKind, + }, + server_util::authorization::XMatrix, }; use serde::Deserialize; use tracing::{error, warn}; use super::{Ar, Ra}; -use crate::{service::appservice::RegistrationInfo, services, Error, Result}; +use crate::{Error, Result, service::appservice::RegistrationInfo, services}; enum Token { Appservice(Box), @@ -122,7 +121,7 @@ async fn ar_from_request_inner( soft_logout: false, }, "Unknown access token.", - )) + )); } (AuthScheme::AccessToken, Token::Appservice(info)) => { let user_id = query_params diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 9c29b60b..f5d4fdd6 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -7,12 +7,18 @@ use std::{ time::Instant, }; -use axum::{response::IntoResponse, Json}; +use axum::{Json, response::IntoResponse}; use axum_extra::headers::{Authorization, HeaderMapExt}; use base64::Engine as _; use get_profile_information::v1::ProfileField; use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, + MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName, + OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId, + ServerName, Signatures, api::{ + EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest, + OutgoingResponse, SendAccessToken, client::error::{Error as RumaError, ErrorKind}, federation::{ authenticated_media, @@ -21,7 +27,7 @@ use ruma::{ device::get_devices::{self, v1::UserDevice}, directory::{get_public_rooms, get_public_rooms_filtered}, discovery::{ - get_server_keys, get_server_version, ServerSigningKeys, + ServerSigningKeys, get_server_keys, get_server_version, }, event::{ get_event, get_missing_events, get_room_state, @@ -40,43 +46,38 @@ use ruma::{ send_transaction_message, }, }, - EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest, - OutgoingResponse, SendAccessToken, }, directory::{Filter, RoomNetwork}, events::{ + StateEventType, TimelineEventType, receipt::{ReceiptEvent, ReceiptEventContent, ReceiptType}, room::{ join_rules::{JoinRule, RoomJoinRulesEventContent}, member::{MembershipState, RoomMemberEventContent}, }, - StateEventType, TimelineEventType, }, serde::{Base64, JsonObject, Raw}, server_util::authorization::XMatrix, state_res::Event, to_device::DeviceIdOrAllDevices, - uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, - MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName, - OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId, - ServerName, Signatures, + uint, user_id, }; -use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; +use serde_json::value::{RawValue as RawJsonValue, to_raw_value}; use tokio::sync::RwLock; use tracing::{debug, error, field, trace, trace_span, warn}; use super::appservice_server; use crate::{ + Ar, Error, PduEvent, Ra, Result, api::client_server::{self, claim_keys_helper, get_keys_helper}, observability::{FoundIn, Lookup, METRICS}, service::{ globals::SigningKeys, - pdu::{gen_event_id_canonical_json, PduBuilder}, + pdu::{PduBuilder, gen_event_id_canonical_json}, rooms::state::ExtractVersion, }, services, - utils::{self, dbg_truncate_str, MxcData}, - Ar, Error, PduEvent, Ra, Result, + utils::{self, MxcData, dbg_truncate_str}, }; /// Wraps either an literal IP address plus port, or a hostname plus complement @@ -2158,7 +2159,7 @@ pub(crate) async fn media_thumbnail_route( #[cfg(test)] mod tests { - use super::{add_port_to_hostname, get_ip_with_port, FedDest}; + use super::{FedDest, add_port_to_hostname, get_ip_with_port}; #[test] fn ips_get_default_ports() { diff --git a/src/api/well_known.rs b/src/api/well_known.rs index 44210e55..5c309fa4 100644 --- a/src/api/well_known.rs +++ b/src/api/well_known.rs @@ -8,7 +8,7 @@ use ruma::api::{ federation::discovery::discover_homeserver as server, }; -use crate::{services, Ar, Ra}; +use crate::{Ar, Ra, services}; /// Handler for `/.well-known/matrix/server` pub(crate) async fn server( diff --git a/src/cli.rs b/src/cli.rs index 99641790..943bafbc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,7 +8,7 @@ use std::path::PathBuf; use clap::{Parser, Subcommand}; use crate::{ - config::{default_tracing_filter, EnvFilterClone, LogFormat}, + config::{EnvFilterClone, LogFormat, default_tracing_filter}, error, observability, }; diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 71776801..21d055aa 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -4,35 +4,35 @@ use std::{ }; use axum::{ + Router, extract::{ - connect_info::IntoMakeServiceWithConnectInfo, ConnectInfo, - DefaultBodyLimit, FromRequestParts, MatchedPath, + ConnectInfo, DefaultBodyLimit, FromRequestParts, MatchedPath, + connect_info::IntoMakeServiceWithConnectInfo, }, middleware::AddExtension, response::IntoResponse, - routing::{any, get, on, MethodFilter, Route}, - Router, + routing::{MethodFilter, Route, any, get, on}, }; use axum_server::{ + Handle as ServerHandle, Server, accept::Accept, bind, service::SendService, tls_rustls::{RustlsAcceptor, RustlsConfig}, - Handle as ServerHandle, Server, }; use http::{ - header::{self, HeaderName}, Method, StatusCode, Uri, + header::{self, HeaderName}, }; use hyper::body::Incoming; use proxy_header::ProxyHeader; use ruma::api::{ + IncomingRequest, client::{ error::{Error as RumaError, ErrorBody, ErrorKind}, uiaa::UiaaResponse, }, federation::discovery::get_server_version, - IncomingRequest, }; use tokio::{ io::{AsyncRead, AsyncWrite}, @@ -42,14 +42,15 @@ use tokio::{ }; use tower::{Layer, Service, ServiceBuilder}; use tower_http::{ + ServiceBuilderExt as _, cors::{self, CorsLayer}, trace::TraceLayer, - ServiceBuilderExt as _, }; -use tracing::{debug, info, info_span, warn, Instrument}; +use tracing::{Instrument, debug, info, info_span, warn}; use super::ServeArgs; use crate::{ + ApplicationState, Services, api::{ client_server, ruma_wrapper::{Ar, Ra}, @@ -64,7 +65,6 @@ use crate::{ error::{Error, Result}, proxy_protocol::{ProxyAcceptor, ProxyAcceptorConfig}, }, - ApplicationState, Services, }; pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> { diff --git a/src/config.rs b/src/config.rs index d3100f41..d27cb39e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,8 +9,8 @@ use std::{ use reqwest::Url; use ruma::{ - api::federation::discovery::OldVerifyKey, OwnedServerName, - OwnedServerSigningKeyId, RoomVersionId, UInt, + OwnedServerName, OwnedServerSigningKeyId, RoomVersionId, UInt, + api::federation::discovery::OldVerifyKey, }; use serde::Deserialize; use strum::{Display, EnumIter, IntoEnumIterator}; @@ -415,7 +415,7 @@ impl Default for FederationConfig { enable: true, self_test: true, trusted_servers: vec![ - OwnedServerName::try_from("matrix.org").unwrap() + OwnedServerName::try_from("matrix.org").unwrap(), ], max_fetch_prev_events: 100, max_concurrent_requests: 100, diff --git a/src/config/env_filter_clone.rs b/src/config/env_filter_clone.rs index c4325fc2..b4fe88b2 100644 --- a/src/config/env_filter_clone.rs +++ b/src/config/env_filter_clone.rs @@ -7,7 +7,7 @@ use std::{fmt, str::FromStr}; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; use tracing_subscriber::EnvFilter; /// A workaround for [`EnvFilter`] not directly implementing [`Clone`] diff --git a/src/database.rs b/src/database.rs index acfcda2b..70dd4299 100644 --- a/src/database.rs +++ b/src/database.rs @@ -8,13 +8,14 @@ use std::{ }; use ruma::{ - events::{push_rules::PushRulesEvent, GlobalAccountDataEventType}, - push::Ruleset, EventId, OwnedRoomId, RoomId, UserId, + events::{GlobalAccountDataEventType, push_rules::PushRulesEvent}, + push::Ruleset, }; -use tracing::{debug, error, info, info_span, warn, Instrument}; +use tracing::{Instrument, debug, error, info, info_span, warn}; use crate::{ + Config, Error, Result, config::DatabaseBackend, service::{ media::MediaFileKey, @@ -23,7 +24,7 @@ use crate::{ state_compressor::CompressedStateEvent, }, }, - services, utils, Config, Error, Result, + services, utils, }; pub(crate) mod abstraction; @@ -1031,7 +1032,7 @@ impl KeyValueDatabase { use std::time::{Duration, Instant}; #[cfg(unix)] - use tokio::signal::unix::{signal, SignalKind}; + use tokio::signal::unix::{SignalKind, signal}; use tokio::time::interval; let timer_interval = Duration::from_secs(u64::from( diff --git a/src/database/abstraction/rocksdb.rs b/src/database/abstraction/rocksdb.rs index 90cdb06a..19de5ffc 100644 --- a/src/database/abstraction/rocksdb.rs +++ b/src/database/abstraction/rocksdb.rs @@ -13,9 +13,9 @@ use rocksdb::{ use tracing::Level; use super::{ - super::Config, watchers::Watchers, KeyValueDatabaseEngine, KvTree, + super::Config, KeyValueDatabaseEngine, KvTree, watchers::Watchers, }; -use crate::{utils, Result}; +use crate::{Result, utils}; pub(crate) struct Engine { rocks: DBWithThreadMode, diff --git a/src/database/abstraction/sqlite.rs b/src/database/abstraction/sqlite.rs index 7b41fc79..e369dd72 100644 --- a/src/database/abstraction/sqlite.rs +++ b/src/database/abstraction/sqlite.rs @@ -11,8 +11,8 @@ use rusqlite::{Connection, DatabaseName::Main, OptionalExtension}; use thread_local::ThreadLocal; use tracing::debug; -use super::{watchers::Watchers, KeyValueDatabaseEngine, KvTree}; -use crate::{database::Config, Result}; +use super::{KeyValueDatabaseEngine, KvTree, watchers::Watchers}; +use crate::{Result, database::Config}; thread_local! { static READ_CONNECTION: RefCell> = diff --git a/src/database/abstraction/watchers.rs b/src/database/abstraction/watchers.rs index b31bd082..91b0da83 100644 --- a/src/database/abstraction/watchers.rs +++ b/src/database/abstraction/watchers.rs @@ -1,5 +1,5 @@ use std::{ - collections::{hash_map, HashMap}, + collections::{HashMap, hash_map}, future::Future, pin::Pin, sync::RwLock, diff --git a/src/database/key_value/account_data.rs b/src/database/key_value/account_data.rs index 9033ac90..4e809799 100644 --- a/src/database/key_value/account_data.rs +++ b/src/database/key_value/account_data.rs @@ -1,14 +1,14 @@ use std::collections::HashMap; use ruma::{ + RoomId, UserId, api::client::error::ErrorKind, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, serde::Raw, - RoomId, UserId, }; use crate::{ - database::KeyValueDatabase, service, services, utils, Error, Result, + Error, Result, database::KeyValueDatabase, service, services, utils, }; impl service::account_data::Data for KeyValueDatabase { diff --git a/src/database/key_value/appservice.rs b/src/database/key_value/appservice.rs index b1ef80c0..79f18753 100644 --- a/src/database/key_value/appservice.rs +++ b/src/database/key_value/appservice.rs @@ -1,6 +1,6 @@ use ruma::api::appservice::Registration; -use crate::{database::KeyValueDatabase, service, utils, Error, Result}; +use crate::{Error, Result, database::KeyValueDatabase, service, utils}; impl service::appservice::Data for KeyValueDatabase { /// Registers an appservice and returns the ID to the caller diff --git a/src/database/key_value/globals.rs b/src/database/key_value/globals.rs index e3293571..226a0787 100644 --- a/src/database/key_value/globals.rs +++ b/src/database/key_value/globals.rs @@ -1,15 +1,16 @@ use async_trait::async_trait; -use futures_util::{stream::FuturesUnordered, StreamExt}; +use futures_util::{StreamExt, stream::FuturesUnordered}; use ruma::{ + DeviceId, ServerName, UserId, api::federation::discovery::{OldVerifyKey, ServerSigningKeys}, signatures::Ed25519KeyPair, - DeviceId, ServerName, UserId, }; use crate::{ + Error, Result, database::KeyValueDatabase, service::{self, globals::SigningKeys}, - services, utils, Error, Result, + services, utils, }; pub(crate) const COUNTER: &[u8] = b"c"; diff --git a/src/database/key_value/key_backups.rs b/src/database/key_value/key_backups.rs index 84140c93..ef614d45 100644 --- a/src/database/key_value/key_backups.rs +++ b/src/database/key_value/key_backups.rs @@ -1,16 +1,16 @@ use std::collections::BTreeMap; use ruma::{ + OwnedRoomId, RoomId, UserId, api::client::{ backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup}, error::ErrorKind, }, serde::Raw, - OwnedRoomId, RoomId, UserId, }; use crate::{ - database::KeyValueDatabase, service, services, utils, Error, Result, + Error, Result, database::KeyValueDatabase, service, services, utils, }; impl service::key_backups::Data for KeyValueDatabase { diff --git a/src/database/key_value/media.rs b/src/database/key_value/media.rs index 53e2146e..1b2f4d22 100644 --- a/src/database/key_value/media.rs +++ b/src/database/key_value/media.rs @@ -1,12 +1,13 @@ use ruma::OwnedMxcUri; use crate::{ + Error, Result, database::KeyValueDatabase, service::{ self, media::{FileMeta, MediaFileKey}, }, - utils, Error, Result, + utils, }; #[derive(Debug, Eq, PartialEq)] diff --git a/src/database/key_value/pusher.rs b/src/database/key_value/pusher.rs index 000c9a5d..5784d561 100644 --- a/src/database/key_value/pusher.rs +++ b/src/database/key_value/pusher.rs @@ -1,9 +1,9 @@ use ruma::{ - api::client::push::{set_pusher, Pusher}, UserId, + api::client::push::{Pusher, set_pusher}, }; -use crate::{database::KeyValueDatabase, service, utils, Error, Result}; +use crate::{Error, Result, database::KeyValueDatabase, service, utils}; impl service::pusher::Data for KeyValueDatabase { fn set_pusher( diff --git a/src/database/key_value/rooms/alias.rs b/src/database/key_value/rooms/alias.rs index a1355ed2..6abc56ff 100644 --- a/src/database/key_value/rooms/alias.rs +++ b/src/database/key_value/rooms/alias.rs @@ -1,10 +1,10 @@ use ruma::{ - api::client::error::ErrorKind, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, - RoomId, + OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId, + api::client::error::ErrorKind, }; use crate::{ - database::KeyValueDatabase, service, services, utils, Error, Result, + Error, Result, database::KeyValueDatabase, service, services, utils, }; impl service::rooms::alias::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/auth_chain.rs b/src/database/key_value/rooms/auth_chain.rs index b736e524..b3c6117a 100644 --- a/src/database/key_value/rooms/auth_chain.rs +++ b/src/database/key_value/rooms/auth_chain.rs @@ -1,9 +1,10 @@ use std::{collections::HashSet, mem::size_of}; use crate::{ + Result, database::KeyValueDatabase, service::{self, rooms::short::ShortEventId}, - utils, Result, + utils, }; impl service::rooms::auth_chain::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/directory.rs b/src/database/key_value/rooms/directory.rs index 58964927..ac198c35 100644 --- a/src/database/key_value/rooms/directory.rs +++ b/src/database/key_value/rooms/directory.rs @@ -1,6 +1,6 @@ use ruma::{OwnedRoomId, RoomId}; -use crate::{database::KeyValueDatabase, service, utils, Error, Result}; +use crate::{Error, Result, database::KeyValueDatabase, service, utils}; impl service::rooms::directory::Data for KeyValueDatabase { #[tracing::instrument(skip(self))] diff --git a/src/database/key_value/rooms/edus/read_receipt.rs b/src/database/key_value/rooms/edus/read_receipt.rs index f8e1470f..93f16230 100644 --- a/src/database/key_value/rooms/edus/read_receipt.rs +++ b/src/database/key_value/rooms/edus/read_receipt.rs @@ -1,10 +1,10 @@ use ruma::{ - events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, - OwnedUserId, RoomId, UserId, + CanonicalJsonObject, OwnedUserId, RoomId, UserId, + events::receipt::ReceiptEvent, serde::Raw, }; use crate::{ - database::KeyValueDatabase, service, services, utils, Error, Result, + Error, Result, database::KeyValueDatabase, service, services, utils, }; impl service::rooms::edus::read_receipt::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/lazy_load.rs b/src/database/key_value/rooms/lazy_load.rs index 01952379..7214f5d3 100644 --- a/src/database/key_value/rooms/lazy_load.rs +++ b/src/database/key_value/rooms/lazy_load.rs @@ -1,6 +1,6 @@ use ruma::{DeviceId, RoomId, UserId}; -use crate::{database::KeyValueDatabase, service, Result}; +use crate::{Result, database::KeyValueDatabase, service}; impl service::rooms::lazy_loading::Data for KeyValueDatabase { fn lazy_load_was_sent_before( diff --git a/src/database/key_value/rooms/metadata.rs b/src/database/key_value/rooms/metadata.rs index dc8c7a19..9b218875 100644 --- a/src/database/key_value/rooms/metadata.rs +++ b/src/database/key_value/rooms/metadata.rs @@ -1,7 +1,7 @@ use ruma::{OwnedRoomId, RoomId}; use crate::{ - database::KeyValueDatabase, service, services, utils, Error, Result, + Error, Result, database::KeyValueDatabase, service, services, utils, }; impl service::rooms::metadata::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/outlier.rs b/src/database/key_value/rooms/outlier.rs index 562331ef..649684f3 100644 --- a/src/database/key_value/rooms/outlier.rs +++ b/src/database/key_value/rooms/outlier.rs @@ -1,6 +1,6 @@ use ruma::{CanonicalJsonObject, EventId}; -use crate::{database::KeyValueDatabase, service, Error, Result}; +use crate::{Error, Result, database::KeyValueDatabase, service}; impl service::rooms::outlier::Data for KeyValueDatabase { fn get_outlier_pdu_json( diff --git a/src/database/key_value/rooms/pdu_metadata.rs b/src/database/key_value/rooms/pdu_metadata.rs index 2376e334..ac547347 100644 --- a/src/database/key_value/rooms/pdu_metadata.rs +++ b/src/database/key_value/rooms/pdu_metadata.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use ruma::{EventId, RoomId, UserId}; use crate::{ + Error, PduEvent, Result, database::KeyValueDatabase, service::{ self, @@ -11,7 +12,7 @@ use crate::{ timeline::{PduCount, PduId}, }, }, - services, utils, Error, PduEvent, Result, + services, utils, }; impl service::rooms::pdu_metadata::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/search.rs b/src/database/key_value/rooms/search.rs index 510feca5..3daf3d8a 100644 --- a/src/database/key_value/rooms/search.rs +++ b/src/database/key_value/rooms/search.rs @@ -1,12 +1,13 @@ use ruma::RoomId; use crate::{ + Result, database::KeyValueDatabase, service::{ self, rooms::{short::ShortRoomId, timeline::PduId}, }, - services, utils, Result, + services, utils, }; /// Splits a string into tokens used as keys in the search inverted index diff --git a/src/database/key_value/rooms/short.rs b/src/database/key_value/rooms/short.rs index ee137733..4766f5a6 100644 --- a/src/database/key_value/rooms/short.rs +++ b/src/database/key_value/rooms/short.rs @@ -1,8 +1,9 @@ use std::sync::Arc; -use ruma::{events::StateEventType, EventId, RoomId}; +use ruma::{EventId, RoomId, events::StateEventType}; use crate::{ + Error, Result, database::KeyValueDatabase, service::{ self, @@ -10,7 +11,7 @@ use crate::{ ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey, }, }, - services, utils, Error, Result, + services, utils, }; impl service::rooms::short::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/state.rs b/src/database/key_value/rooms/state.rs index b7cbcb39..370f337f 100644 --- a/src/database/key_value/rooms/state.rs +++ b/src/database/key_value/rooms/state.rs @@ -3,6 +3,7 @@ use std::{collections::HashSet, sync::Arc}; use ruma::{EventId, OwnedEventId, OwnedRoomId, RoomId}; use crate::{ + Error, Result, database::KeyValueDatabase, service::{ self, @@ -10,7 +11,6 @@ use crate::{ rooms::short::{ShortEventId, ShortStateHash}, }, utils::{self, on_demand_hashmap::KeyToken}, - Error, Result, }; impl service::rooms::state::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/state_accessor.rs b/src/database/key_value/rooms/state_accessor.rs index 1e9e1b64..ad83951c 100644 --- a/src/database/key_value/rooms/state_accessor.rs +++ b/src/database/key_value/rooms/state_accessor.rs @@ -1,9 +1,10 @@ use ruma::EventId; use crate::{ + Error, Result, database::KeyValueDatabase, service::{self, rooms::short::ShortStateHash}, - utils, Error, Result, + utils, }; impl service::rooms::state_accessor::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/state_cache.rs b/src/database/key_value/rooms/state_cache.rs index c90a18b1..3ea19011 100644 --- a/src/database/key_value/rooms/state_cache.rs +++ b/src/database/key_value/rooms/state_cache.rs @@ -1,15 +1,16 @@ use std::collections::HashSet; use ruma::{ + OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, events::{AnyStrippedStateEvent, AnySyncStateEvent}, serde::Raw, - OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, }; use crate::{ + Error, Result, database::KeyValueDatabase, service::{self, appservice::RegistrationInfo}, - services, utils, Error, Result, + services, utils, }; impl service::rooms::state_cache::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/state_compressor.rs b/src/database/key_value/rooms/state_compressor.rs index 4f487ce2..3b3b7bcc 100644 --- a/src/database/key_value/rooms/state_compressor.rs +++ b/src/database/key_value/rooms/state_compressor.rs @@ -1,15 +1,16 @@ use std::{collections::HashSet, mem::size_of, sync::Arc}; use crate::{ + Error, Result, database::KeyValueDatabase, service::{ self, rooms::{ short::ShortStateHash, - state_compressor::{data::StateDiff, CompressedStateEvent}, + state_compressor::{CompressedStateEvent, data::StateDiff}, }, }, - utils, Error, Result, + utils, }; impl service::rooms::state_compressor::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/threads.rs b/src/database/key_value/rooms/threads.rs index 8f331d4f..28e2e14f 100644 --- a/src/database/key_value/rooms/threads.rs +++ b/src/database/key_value/rooms/threads.rs @@ -1,12 +1,13 @@ use ruma::{ - api::client::threads::get_threads::v1::IncludeThreads, OwnedUserId, RoomId, - UserId, + OwnedUserId, RoomId, UserId, + api::client::threads::get_threads::v1::IncludeThreads, }; use crate::{ + Error, PduEvent, Result, database::KeyValueDatabase, service::{self, rooms::timeline::PduId}, - services, utils, Error, PduEvent, Result, + services, utils, }; impl service::rooms::threads::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/timeline.rs b/src/database/key_value/rooms/timeline.rs index b46e9bfe..655708df 100644 --- a/src/database/key_value/rooms/timeline.rs +++ b/src/database/key_value/rooms/timeline.rs @@ -1,15 +1,16 @@ use std::{mem::size_of, sync::Arc}; use ruma::{ - api::client::error::ErrorKind, CanonicalJsonObject, EventId, OwnedUserId, - RoomId, UserId, + CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId, + api::client::error::ErrorKind, }; use service::rooms::timeline::PduCount; use crate::{ + Error, PduEvent, Result, database::KeyValueDatabase, service::{self, rooms::timeline::PduId}, - services, utils, Error, PduEvent, Result, + services, utils, }; impl service::rooms::timeline::Data for KeyValueDatabase { diff --git a/src/database/key_value/rooms/user.rs b/src/database/key_value/rooms/user.rs index 09d87378..d65d622a 100644 --- a/src/database/key_value/rooms/user.rs +++ b/src/database/key_value/rooms/user.rs @@ -1,9 +1,10 @@ use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId}; use crate::{ + Error, Result, database::KeyValueDatabase, service::{self, rooms::short::ShortStateHash}, - services, utils, Error, Result, + services, utils, }; impl service::rooms::user::Data for KeyValueDatabase { diff --git a/src/database/key_value/sending.rs b/src/database/key_value/sending.rs index 1f7db867..c2d56763 100644 --- a/src/database/key_value/sending.rs +++ b/src/database/key_value/sending.rs @@ -1,13 +1,14 @@ -use ruma::{serde::Raw, ServerName, UserId}; +use ruma::{ServerName, UserId, serde::Raw}; use crate::{ + Error, Result, database::KeyValueDatabase, service::{ self, rooms::timeline::PduId, sending::{Destination, RequestKey, SendingEventType}, }, - services, utils, Error, Result, + services, utils, }; impl service::sending::Data for KeyValueDatabase { diff --git a/src/database/key_value/transaction_ids.rs b/src/database/key_value/transaction_ids.rs index 345b74a1..f2ac1560 100644 --- a/src/database/key_value/transaction_ids.rs +++ b/src/database/key_value/transaction_ids.rs @@ -1,6 +1,6 @@ use ruma::{DeviceId, TransactionId, UserId}; -use crate::{database::KeyValueDatabase, service, Result}; +use crate::{Result, database::KeyValueDatabase, service}; impl service::transaction_ids::Data for KeyValueDatabase { fn add_txnid( diff --git a/src/database/key_value/uiaa.rs b/src/database/key_value/uiaa.rs index e97f915e..d52ea518 100644 --- a/src/database/key_value/uiaa.rs +++ b/src/database/key_value/uiaa.rs @@ -1,9 +1,9 @@ use ruma::{ - api::client::{error::ErrorKind, uiaa::UiaaInfo}, DeviceId, UserId, + api::client::{error::ErrorKind, uiaa::UiaaInfo}, }; -use crate::{database::KeyValueDatabase, service, Error, Result}; +use crate::{Error, Result, database::KeyValueDatabase, service}; impl service::uiaa::Data for KeyValueDatabase { fn update_uiaa_session( diff --git a/src/database/key_value/users.rs b/src/database/key_value/users.rs index e3fdb95e..c825a006 100644 --- a/src/database/key_value/users.rs +++ b/src/database/key_value/users.rs @@ -1,20 +1,21 @@ use std::{collections::BTreeMap, mem::size_of}; use ruma::{ + DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName, + OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId, + UInt, UserId, api::client::{device::Device, error::ErrorKind, filter::FilterDefinition}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, events::{AnyToDeviceEvent, StateEventType}, serde::Raw, - DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName, - OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId, - UInt, UserId, }; use tracing::warn; use crate::{ + Error, Result, database::KeyValueDatabase, service::{self, users::clean_signatures}, - services, utils, Error, Result, + services, utils, }; impl service::users::Data for KeyValueDatabase { diff --git a/src/main.rs b/src/main.rs index 8f4268a1..072813ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ mod utils; pub(crate) use api::ruma_wrapper::{Ar, Ra}; pub(crate) use config::Config; -pub(crate) use service::{pdu::PduEvent, services, Services}; +pub(crate) use service::{Services, pdu::PduEvent, services}; pub(crate) use utils::error::{Error, Result}; #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] @@ -114,7 +114,7 @@ async fn main() -> ExitCode { #[cfg(unix)] #[tracing::instrument(err)] fn maximize_fd_limit() -> Result<(), nix::errno::Errno> { - use nix::sys::resource::{getrlimit, setrlimit, Resource}; + use nix::sys::resource::{Resource, getrlimit, setrlimit}; use tracing::debug; let res = Resource::RLIMIT_NOFILE; diff --git a/src/observability.rs b/src/observability.rs index 0f136306..19ddd3d4 100644 --- a/src/observability.rs +++ b/src/observability.rs @@ -14,22 +14,23 @@ use axum::{ response::Response, }; use http::Method; -use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue}; +use opentelemetry::{KeyValue, metrics::MeterProvider, trace::TracerProvider}; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{ - metrics::{new_view, Aggregation, Instrument, SdkMeterProvider, Stream}, Resource, + metrics::{Aggregation, Instrument, SdkMeterProvider, Stream, new_view}, }; use strum::{AsRefStr, IntoStaticStr}; use thiserror::Error; use tokio::time::Instant; -use tracing::{subscriber::SetGlobalDefaultError, Span}; +use tracing::{Span, subscriber::SetGlobalDefaultError}; use tracing_flame::{FlameLayer, FlushGuard}; use tracing_opentelemetry::OtelData; use tracing_subscriber::{ + EnvFilter, Layer, Registry, layer::SubscriberExt, registry::{LookupSpan, SpanData}, - reload, EnvFilter, Layer, Registry, + reload, }; use crate::{ diff --git a/src/service.rs b/src/service.rs index 85e7a302..48c1cd64 100644 --- a/src/service.rs +++ b/src/service.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, OnceLock}; -use crate::{observability::FilterReloadHandles, Config, Result}; +use crate::{Config, Result, observability::FilterReloadHandles}; pub(crate) mod account_data; pub(crate) mod admin; diff --git a/src/service/account_data/data.rs b/src/service/account_data/data.rs index 04d4bf76..833e0b1a 100644 --- a/src/service/account_data/data.rs +++ b/src/service/account_data/data.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use ruma::{ + RoomId, UserId, events::{AnyEphemeralRoomEvent, RoomAccountDataEventType}, serde::Raw, - RoomId, UserId, }; use crate::Result; diff --git a/src/service/admin.rs b/src/service/admin.rs index 5e3ee770..e3377616 100644 --- a/src/service/admin.rs +++ b/src/service/admin.rs @@ -3,8 +3,11 @@ use std::{collections::BTreeMap, fmt::Write, sync::Arc, time::Instant}; use clap::{Parser, Subcommand, ValueEnum}; use regex::Regex; use ruma::{ + EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId, + OwnedServerName, RoomId, RoomVersionId, ServerName, UserId, api::appservice::Registration, events::{ + TimelineEventType, push_rules::{PushRulesEvent, PushRulesEventContent}, room::{ canonical_alias::RoomCanonicalAliasEventContent, @@ -20,22 +23,19 @@ use ruma::{ power_levels::RoomPowerLevelsEventContent, topic::RoomTopicEventContent, }, - TimelineEventType, }, signatures::verify_json, - EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId, - OwnedServerName, RoomId, RoomVersionId, ServerName, UserId, }; use serde_json::value::to_raw_value; -use tokio::sync::{mpsc, Mutex, RwLock}; +use tokio::sync::{Mutex, RwLock, mpsc}; use tracing::warn; use super::pdu::PduBuilder; use crate::{ - api::client_server::{leave_all_rooms, AUTO_GEN_PASSWORD_LENGTH}, + Error, PduEvent, Result, + api::client_server::{AUTO_GEN_PASSWORD_LENGTH, leave_all_rooms}, services, utils::{self, dbg_truncate_str, room_version::RoomVersion}, - Error, PduEvent, Result, }; #[derive(Debug, Parser)] @@ -691,7 +691,7 @@ impl Service { "The supplied username is not a valid \ username: {e}" ), - )) + )); } }; @@ -746,7 +746,7 @@ impl Service { "The supplied username is not a valid \ username: {e}" ), - )) + )); } }; if user_id.is_historical() { diff --git a/src/service/appservice.rs b/src/service/appservice.rs index 8174d2e4..dea788a4 100644 --- a/src/service/appservice.rs +++ b/src/service/appservice.rs @@ -3,8 +3,8 @@ use std::collections::BTreeMap; use futures_util::Future; use regex::RegexSet; use ruma::{ - api::appservice::{Namespace, Registration}, RoomAliasId, UserId, + api::appservice::{Namespace, Registration}, }; use tokio::sync::RwLock; diff --git a/src/service/globals.rs b/src/service/globals.rs index 7ba34e0d..9c39e626 100644 --- a/src/service/globals.rs +++ b/src/service/globals.rs @@ -7,13 +7,13 @@ use std::{ net::{IpAddr, SocketAddr}, path::PathBuf, sync::{ - atomic::{self, AtomicBool}, Arc, RwLock as StdRwLock, + atomic::{self, AtomicBool}, }, time::{Duration, Instant}, }; -use base64::{engine::general_purpose, Engine as _}; +use base64::{Engine as _, engine::general_purpose}; use futures_util::FutureExt; use hyper::service::Service as _; use hyper_util::{ @@ -21,29 +21,29 @@ use hyper_util::{ }; use reqwest::dns::{Addrs, Name, Resolve, Resolving}; use ruma::{ - api::federation::discovery::ServerSigningKeys, - events::{ - push_rules::PushRulesEventContent, - room::message::RoomMessageEventContent, GlobalAccountDataEvent, - GlobalAccountDataEventType, - }, - push::Ruleset, - serde::Base64, DeviceId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomAliasId, OwnedRoomId, OwnedServerName, OwnedUserId, RoomAliasId, RoomVersionId, ServerName, UInt, UserId, + api::federation::discovery::ServerSigningKeys, + events::{ + GlobalAccountDataEvent, GlobalAccountDataEventType, + push_rules::PushRulesEventContent, + room::message::RoomMessageEventContent, + }, + push::Ruleset, + serde::Base64, }; -use tokio::sync::{broadcast, Mutex, RwLock, Semaphore}; -use tracing::{error, warn, Instrument}; +use tokio::sync::{Mutex, RwLock, Semaphore, broadcast}; +use tracing::{Instrument, error, warn}; use trust_dns_resolver::TokioAsyncResolver; use crate::{ + Config, Error, Result, api::server_server::FedDest, observability::FilterReloadHandles, service::media::MediaFileKey, services, utils::on_demand_hashmap::{OnDemandHashMap, TokenSet}, - Config, Error, Result, }; mod data; diff --git a/src/service/globals/data.rs b/src/service/globals/data.rs index 124e81b3..8fb26ea3 100644 --- a/src/service/globals/data.rs +++ b/src/service/globals/data.rs @@ -5,14 +5,14 @@ use std::{ use async_trait::async_trait; use ruma::{ + DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId, api::federation::discovery::{OldVerifyKey, ServerSigningKeys, VerifyKey}, serde::Base64, signatures::Ed25519KeyPair, - DeviceId, MilliSecondsSinceUnixEpoch, ServerName, UserId, }; use serde::Deserialize; -use crate::{services, Result}; +use crate::{Result, services}; /// Similar to [`ServerSigningKeys`], but drops a few unnecessary fields we /// don't require post-validation @@ -88,7 +88,7 @@ pub(crate) trait Data: Send + Sync { fn next_count(&self) -> Result; fn current_count(&self) -> Result; async fn watch(&self, user_id: &UserId, device_id: &DeviceId) - -> Result<()>; + -> Result<()>; fn cleanup(&self) -> Result<()>; fn load_keypair(&self) -> Result; fn remove_keypair(&self) -> Result<()>; diff --git a/src/service/key_backups/data.rs b/src/service/key_backups/data.rs index 0b667192..b11278ad 100644 --- a/src/service/key_backups/data.rs +++ b/src/service/key_backups/data.rs @@ -1,9 +1,9 @@ use std::collections::BTreeMap; use ruma::{ + OwnedRoomId, RoomId, UserId, api::client::backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup}, serde::Raw, - OwnedRoomId, RoomId, UserId, }; use crate::Result; diff --git a/src/service/media.rs b/src/service/media.rs index 9b965caa..876b52c5 100644 --- a/src/service/media.rs +++ b/src/service/media.rs @@ -2,8 +2,8 @@ use std::io::Cursor; use image::imageops::FilterType; use ruma::{ - api::client::error::ErrorKind, http_headers::ContentDisposition, - OwnedMxcUri, + OwnedMxcUri, api::client::error::ErrorKind, + http_headers::ContentDisposition, }; use tokio::{ fs::{self, File}, @@ -11,7 +11,7 @@ use tokio::{ }; use tracing::{debug, warn}; -use crate::{services, utils, Error, Result}; +use crate::{Error, Result, services, utils}; mod data; @@ -392,7 +392,7 @@ impl Service { let mut file = match File::open(path).await { Ok(file) => file, Err(e) if e.kind() == std::io::ErrorKind::NotFound => { - return Ok(None) + return Ok(None); } Err(e) => return Err(e.into()), }; diff --git a/src/service/pdu.rs b/src/service/pdu.rs index b6052a4c..57ae43af 100644 --- a/src/service/pdu.rs +++ b/src/service/pdu.rs @@ -1,26 +1,27 @@ use std::{cmp::Ordering, collections::BTreeMap, sync::Arc}; use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, + MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, + RoomVersionId, UInt, UserId, canonical_json::redact_content_in_place, events::{ + AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, + AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, + AnyTimelineEvent, StateEvent, TimelineEventType, room::{ member::RoomMemberEventContent, redaction::RoomRedactionEventContent, }, space::child::HierarchySpaceChildEvent, - AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, - AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, - AnyTimelineEvent, StateEvent, TimelineEventType, }, serde::Raw, - state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, - MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, - RoomVersionId, UInt, UserId, + state_res, }; use serde::{Deserialize, Serialize}; use serde_json::{ json, - value::{to_raw_value, RawValue as RawJsonValue}, + value::{RawValue as RawJsonValue, to_raw_value}, }; use tracing::warn; diff --git a/src/service/pusher.rs b/src/service/pusher.rs index c2ae7c46..e5d6bdf5 100644 --- a/src/service/pusher.rs +++ b/src/service/pusher.rs @@ -2,30 +2,31 @@ use std::{fmt::Debug, mem}; use bytes::BytesMut; use ruma::{ + RoomId, UInt, UserId, api::{ - client::push::{set_pusher, Pusher, PusherKind}, + IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken, + client::push::{Pusher, PusherKind, set_pusher}, push_gateway::send_event_notification::{ self, v1::{ Device, Notification, NotificationCounts, NotificationPriority, }, }, - IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken, }, events::{ - room::power_levels::RoomPowerLevelsEventContent, AnySyncTimelineEvent, - StateEventType, TimelineEventType, + AnySyncTimelineEvent, StateEventType, TimelineEventType, + room::power_levels::RoomPowerLevelsEventContent, }, push::{ Action, PushConditionPowerLevelsCtx, PushConditionRoomCtx, PushFormat, Ruleset, Tweak, }, serde::Raw, - uint, RoomId, UInt, UserId, + uint, }; use tracing::warn; -use crate::{services, utils, Error, PduEvent, Result}; +use crate::{Error, PduEvent, Result, services, utils}; mod data; diff --git a/src/service/pusher/data.rs b/src/service/pusher/data.rs index 9fcba933..02f2b36f 100644 --- a/src/service/pusher/data.rs +++ b/src/service/pusher/data.rs @@ -1,6 +1,6 @@ use ruma::{ - api::client::push::{set_pusher, Pusher}, UserId, + api::client::push::{Pusher, set_pusher}, }; use crate::Result; diff --git a/src/service/rooms/alias.rs b/src/service/rooms/alias.rs index 638d4d92..b0f1dd37 100644 --- a/src/service/rooms/alias.rs +++ b/src/service/rooms/alias.rs @@ -1,10 +1,10 @@ use http::StatusCode; use ruma::{ - api::{client::error::ErrorKind, federation}, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId, UserId, + api::{client::error::ErrorKind, federation}, }; -use crate::{services, Error, Result}; +use crate::{Error, Result, services}; mod data; diff --git a/src/service/rooms/auth_chain.rs b/src/service/rooms/auth_chain.rs index 3c8e4b38..63cb2a5d 100644 --- a/src/service/rooms/auth_chain.rs +++ b/src/service/rooms/auth_chain.rs @@ -4,15 +4,15 @@ use std::{ }; use lru_cache::LruCache; -use ruma::{api::client::error::ErrorKind, EventId, RoomId}; +use ruma::{EventId, RoomId, api::client::error::ErrorKind}; use tracing::{debug, error, warn}; use super::short::ShortEventId; use crate::{ + Error, Result, observability::{FoundIn, Lookup, METRICS}, services, utils::debug_slice_truncated, - Error, Result, }; mod data; diff --git a/src/service/rooms/auth_chain/data.rs b/src/service/rooms/auth_chain/data.rs index 9dc855d2..e12c0cbb 100644 --- a/src/service/rooms/auth_chain/data.rs +++ b/src/service/rooms/auth_chain/data.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use crate::{service::rooms::short::ShortEventId, Result}; +use crate::{Result, service::rooms::short::ShortEventId}; pub(crate) trait Data: Send + Sync { fn get_cached_eventid_authchain( diff --git a/src/service/rooms/edus/read_receipt/data.rs b/src/service/rooms/edus/read_receipt/data.rs index b48ec9e2..1d972d2e 100644 --- a/src/service/rooms/edus/read_receipt/data.rs +++ b/src/service/rooms/edus/read_receipt/data.rs @@ -1,5 +1,5 @@ use ruma::{ - events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId, + OwnedUserId, RoomId, UserId, events::receipt::ReceiptEvent, serde::Raw, }; use crate::Result; diff --git a/src/service/rooms/edus/typing.rs b/src/service/rooms/edus/typing.rs index 097fed27..7f0bf860 100644 --- a/src/service/rooms/edus/typing.rs +++ b/src/service/rooms/edus/typing.rs @@ -1,13 +1,13 @@ use std::collections::BTreeMap; use ruma::{ - events::{typing::TypingEventContent, SyncEphemeralRoomEvent}, OwnedRoomId, OwnedUserId, RoomId, UserId, + events::{SyncEphemeralRoomEvent, typing::TypingEventContent}, }; -use tokio::sync::{broadcast, RwLock}; +use tokio::sync::{RwLock, broadcast}; use tracing::trace; -use crate::{services, utils, Result}; +use crate::{Result, services, utils}; pub(crate) struct Service { // u64 is unix timestamp of timeout diff --git a/src/service/rooms/event_handler.rs b/src/service/rooms/event_handler.rs index 1543e423..fb31ea9e 100644 --- a/src/service/rooms/event_handler.rs +++ b/src/service/rooms/event_handler.rs @@ -1,11 +1,14 @@ use std::{ - collections::{hash_map, BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet, hash_map}, sync::Arc, time::{Duration, Instant, SystemTime}, }; -use futures_util::{future::BoxFuture, stream::FuturesUnordered, StreamExt}; +use futures_util::{StreamExt, future::BoxFuture, stream::FuturesUnordered}; use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, + MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId, + RoomId, RoomVersionId, ServerName, api::{ client::error::ErrorKind, federation::{ @@ -19,17 +22,15 @@ use ruma::{ }, }, events::{ + StateEventType, TimelineEventType, room::{ redaction::RoomRedactionEventContent, server_acl::RoomServerAclEventContent, }, - StateEventType, TimelineEventType, }, int, state_res::{self, StateMap}, - uint, CanonicalJsonObject, CanonicalJsonValue, EventId, - MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId, - RoomId, RoomVersionId, ServerName, + uint, }; use serde::Deserialize; use serde_json::value::RawValue as RawJsonValue; @@ -41,10 +42,10 @@ use super::{ timeline::PduId, }; use crate::{ + Error, PduEvent, Result, service::{globals::SigningKeys, pdu, rooms::state::ExtractVersion}, services, utils::{debug_slice_truncated, room_version::RoomVersion}, - Error, PduEvent, Result, }; #[derive(Deserialize)] @@ -820,7 +821,7 @@ impl Service { return Err(Error::bad_database( "State event's type and state_key \ combination exists multiple times.", - )) + )); } } } diff --git a/src/service/rooms/pdu_metadata.rs b/src/service/rooms/pdu_metadata.rs index 8bb62746..2fe0bddb 100644 --- a/src/service/rooms/pdu_metadata.rs +++ b/src/service/rooms/pdu_metadata.rs @@ -1,14 +1,14 @@ use std::sync::Arc; use ruma::{ - api::client::relations::get_relating_events, - events::{relation::RelationType, TimelineEventType}, EventId, RoomId, UserId, + api::client::relations::get_relating_events, + events::{TimelineEventType, relation::RelationType}, }; use serde::Deserialize; use super::timeline::PduCount; -use crate::{services, PduEvent, Result}; +use crate::{PduEvent, Result, services}; mod data; diff --git a/src/service/rooms/pdu_metadata/data.rs b/src/service/rooms/pdu_metadata/data.rs index baab44a4..a3fc4c12 100644 --- a/src/service/rooms/pdu_metadata/data.rs +++ b/src/service/rooms/pdu_metadata/data.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use ruma::{EventId, RoomId, UserId}; use crate::{ - service::rooms::{short::ShortRoomId, timeline::PduCount}, PduEvent, Result, + service::rooms::{short::ShortRoomId, timeline::PduCount}, }; pub(crate) trait Data: Send + Sync { diff --git a/src/service/rooms/search/data.rs b/src/service/rooms/search/data.rs index 2372a9aa..ad103ea1 100644 --- a/src/service/rooms/search/data.rs +++ b/src/service/rooms/search/data.rs @@ -1,8 +1,8 @@ use ruma::RoomId; use crate::{ - service::rooms::{short::ShortRoomId, timeline::PduId}, Result, + service::rooms::{short::ShortRoomId, timeline::PduId}, }; pub(crate) trait Data: Send + Sync { diff --git a/src/service/rooms/short.rs b/src/service/rooms/short.rs index ce4d207c..d25f4297 100644 --- a/src/service/rooms/short.rs +++ b/src/service/rooms/short.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use lru_cache::LruCache; -use ruma::{events::StateEventType, EventId, OwnedEventId, RoomId}; +use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType}; use crate::{ observability::{FoundIn, Lookup, METRICS}, diff --git a/src/service/rooms/short/data.rs b/src/service/rooms/short/data.rs index b21588be..a03d5df2 100644 --- a/src/service/rooms/short/data.rs +++ b/src/service/rooms/short/data.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use ruma::{events::StateEventType, EventId, RoomId}; +use ruma::{EventId, RoomId, events::StateEventType}; use super::{ShortEventId, ShortRoomId, ShortStateHash, ShortStateKey}; use crate::Result; diff --git a/src/service/rooms/spaces.rs b/src/service/rooms/spaces.rs index d3c52b1d..ac1a7c36 100644 --- a/src/service/rooms/spaces.rs +++ b/src/service/rooms/spaces.rs @@ -2,14 +2,16 @@ use std::sync::Arc; use lru_cache::LruCache; use ruma::{ + OwnedRoomId, RoomId, UserId, api::{ client::{ error::ErrorKind, - space::{get_hierarchy, SpaceHierarchyRoomsChunk}, + space::{SpaceHierarchyRoomsChunk, get_hierarchy}, }, federation, }, events::{ + StateEventType, room::{ avatar::RoomAvatarEventContent, canonical_alias::RoomCanonicalAliasEventContent, @@ -23,16 +25,14 @@ use ruma::{ topic::RoomTopicEventContent, }, space::child::SpaceChildEventContent, - StateEventType, }, space::SpaceRoomJoinRule, - OwnedRoomId, RoomId, UserId, }; use tokio::sync::Mutex; use tracing::{debug, error, warn}; use super::state::ExtractType; -use crate::{services, Error, PduEvent, Result}; +use crate::{Error, PduEvent, Result, services}; pub(crate) enum CachedJoinRule { Full(JoinRule), @@ -288,7 +288,7 @@ impl Service { _ => { return Err(Error::BadServerResponse( "Unknown join rule", - )) + )); } }; if self.handle_join_rule( diff --git a/src/service/rooms/state.rs b/src/service/rooms/state.rs index 5db98287..a2c6a3dc 100644 --- a/src/service/rooms/state.rs +++ b/src/service/rooms/state.rs @@ -5,27 +5,27 @@ use std::{ }; use ruma::{ + EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId, api::client::error::ErrorKind, events::{ - room::{create::PreviousRoom, member::MembershipState}, AnyStrippedStateEvent, StateEventType, TimelineEventType, + room::{create::PreviousRoom, member::MembershipState}, }, room::RoomType, serde::Raw, state_res::{self, StateMap}, - EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId, }; -use serde::{de::DeserializeOwned, Deserialize}; +use serde::{Deserialize, de::DeserializeOwned}; use tracing::warn; use super::{short::ShortStateHash, state_compressor::CompressedStateEvent}; use crate::{ + Error, PduEvent, Result, service::globals::marker, services, utils::{ calculate_hash, debug_slice_truncated, on_demand_hashmap::KeyToken, }, - Error, PduEvent, Result, }; mod data; diff --git a/src/service/rooms/state/data.rs b/src/service/rooms/state/data.rs index 452c3b1b..8e228146 100644 --- a/src/service/rooms/state/data.rs +++ b/src/service/rooms/state/data.rs @@ -3,12 +3,12 @@ use std::{collections::HashSet, sync::Arc}; use ruma::{EventId, OwnedEventId, OwnedRoomId, RoomId}; use crate::{ + Result, service::{ globals::marker, rooms::short::{ShortEventId, ShortStateHash}, }, utils::on_demand_hashmap::KeyToken, - Result, }; pub(crate) trait Data: Send + Sync { diff --git a/src/service/rooms/state_accessor.rs b/src/service/rooms/state_accessor.rs index e9794e53..e54e4089 100644 --- a/src/service/rooms/state_accessor.rs +++ b/src/service/rooms/state_accessor.rs @@ -5,7 +5,10 @@ use std::{ use lru_cache::LruCache; use ruma::{ + EventId, JsOption, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, + ServerName, UserId, events::{ + StateEventType, room::{ avatar::RoomAvatarEventContent, history_visibility::{ @@ -15,22 +18,19 @@ use ruma::{ name::RoomNameEventContent, power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent}, }, - StateEventType, }, state_res::Event, - EventId, JsOption, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, - ServerName, UserId, }; use serde_json::value::to_raw_value; use tracing::{error, warn}; use super::short::{ShortStateHash, ShortStateKey}; use crate::{ + Error, PduEvent, Result, observability::{FoundIn, Lookup, METRICS}, service::{globals::marker, pdu::PduBuilder}, services, utils::on_demand_hashmap::KeyToken, - Error, PduEvent, Result, }; mod data; diff --git a/src/service/rooms/state_accessor/data.rs b/src/service/rooms/state_accessor/data.rs index 4399dc66..742c1f80 100644 --- a/src/service/rooms/state_accessor/data.rs +++ b/src/service/rooms/state_accessor/data.rs @@ -1,6 +1,6 @@ use ruma::EventId; -use crate::{service::rooms::short::ShortStateHash, Result}; +use crate::{Result, service::rooms::short::ShortStateHash}; pub(crate) trait Data: Send + Sync { /// Returns the state hash for this pdu. diff --git a/src/service/rooms/state_cache.rs b/src/service/rooms/state_cache.rs index ea6721d9..03a2627c 100644 --- a/src/service/rooms/state_cache.rs +++ b/src/service/rooms/state_cache.rs @@ -4,20 +4,21 @@ use std::{ }; use ruma::{ + OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, events::{ - ignored_user_list::IgnoredUserListEvent, room::member::MembershipState, AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType, - RoomAccountDataEventType, + RoomAccountDataEventType, ignored_user_list::IgnoredUserListEvent, + room::member::MembershipState, }, serde::Raw, - OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, }; use tracing::warn; use crate::{ + Error, Result, observability::{FoundIn, Lookup, METRICS}, service::appservice::RegistrationInfo, - services, Error, Result, + services, }; mod data; diff --git a/src/service/rooms/state_cache/data.rs b/src/service/rooms/state_cache/data.rs index a265f99c..196468f6 100644 --- a/src/service/rooms/state_cache/data.rs +++ b/src/service/rooms/state_cache/data.rs @@ -1,12 +1,12 @@ use std::collections::HashSet; use ruma::{ + OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, events::{AnyStrippedStateEvent, AnySyncStateEvent}, serde::Raw, - OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, }; -use crate::{service::appservice::RegistrationInfo, Result}; +use crate::{Result, service::appservice::RegistrationInfo}; pub(crate) trait Data: Send + Sync { fn mark_as_once_joined( diff --git a/src/service/rooms/state_compressor.rs b/src/service/rooms/state_compressor.rs index 60fbb9c5..ef282b3e 100644 --- a/src/service/rooms/state_compressor.rs +++ b/src/service/rooms/state_compressor.rs @@ -10,8 +10,9 @@ use ruma::{EventId, RoomId}; use super::short::{ShortEventId, ShortStateHash, ShortStateKey}; use crate::{ + Result, observability::{FoundIn, Lookup, METRICS}, - services, utils, Result, + services, utils, }; pub(crate) mod data; diff --git a/src/service/rooms/state_compressor/data.rs b/src/service/rooms/state_compressor/data.rs index aafaf009..f97f4358 100644 --- a/src/service/rooms/state_compressor/data.rs +++ b/src/service/rooms/state_compressor/data.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, sync::Arc}; use super::CompressedStateEvent; -use crate::{service::rooms::short::ShortStateHash, Result}; +use crate::{Result, service::rooms::short::ShortStateHash}; pub(crate) struct StateDiff { pub(crate) parent: Option, diff --git a/src/service/rooms/threads.rs b/src/service/rooms/threads.rs index 5acfdec8..0cb970ee 100644 --- a/src/service/rooms/threads.rs +++ b/src/service/rooms/threads.rs @@ -1,11 +1,12 @@ use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, UserId, api::client::{error::ErrorKind, threads::get_threads::v1::IncludeThreads}, events::relation::BundledThread, - uint, CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, UserId, + uint, }; use serde_json::json; -use crate::{services, Error, PduEvent, Result}; +use crate::{Error, PduEvent, Result, services}; mod data; diff --git a/src/service/rooms/threads/data.rs b/src/service/rooms/threads/data.rs index 384c23c8..177bea05 100644 --- a/src/service/rooms/threads/data.rs +++ b/src/service/rooms/threads/data.rs @@ -1,9 +1,9 @@ use ruma::{ - api::client::threads::get_threads::v1::IncludeThreads, OwnedUserId, RoomId, - UserId, + OwnedUserId, RoomId, UserId, + api::client::threads::get_threads::v1::IncludeThreads, }; -use crate::{service::rooms::timeline::PduId, PduEvent, Result}; +use crate::{PduEvent, Result, service::rooms::timeline::PduId}; pub(crate) trait Data: Send + Sync { #[allow(clippy::type_complexity)] diff --git a/src/service/rooms/timeline.rs b/src/service/rooms/timeline.rs index d8cfa368..a6ef2dd4 100644 --- a/src/service/rooms/timeline.rs +++ b/src/service/rooms/timeline.rs @@ -1,14 +1,17 @@ use std::{ cmp::Ordering, - collections::{hash_map, BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet, hash_map}, sync::{Arc, Mutex}, }; use lru_cache::LruCache; use ruma::{ + CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, + OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId, api::{client::error::ErrorKind, federation}, canonical_json::to_canonical_value, events::{ + GlobalAccountDataEventType, StateEventType, TimelineEventType, push_rules::PushRulesEvent, room::{ create::RoomCreateEventContent, encrypted::Relation, @@ -16,31 +19,29 @@ use ruma::{ power_levels::RoomPowerLevelsEventContent, redaction::RoomRedactionEventContent, }, - GlobalAccountDataEventType, StateEventType, TimelineEventType, }, push::{Action, Ruleset, Tweak}, state_res::{self, Event}, - uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, - OwnedEventId, OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId, + uint, user_id, }; use serde::Deserialize; -use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; +use serde_json::value::{RawValue as RawJsonValue, to_raw_value}; use tokio::sync::RwLock; use tracing::{error, info, warn}; use super::{short::ShortRoomId, state_compressor::CompressedStateEvent}; use crate::{ + Error, PduEvent, Result, api::server_server, observability::{FoundIn, Lookup, METRICS}, service::{ appservice::NamespaceRegex, - globals::{marker, SigningKeys}, + globals::{SigningKeys, marker}, pdu::{EventHash, PduBuilder}, rooms::state::ExtractVersion, }, services, utils::{self, on_demand_hashmap::KeyToken, room_version::RoomVersion}, - Error, PduEvent, Result, }; mod data; @@ -921,7 +922,7 @@ impl Service { ErrorKind::Unknown, "Signing event failed", )), - } + }; } } diff --git a/src/service/rooms/timeline/data.rs b/src/service/rooms/timeline/data.rs index 49b0c8a2..a0a297b6 100644 --- a/src/service/rooms/timeline/data.rs +++ b/src/service/rooms/timeline/data.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use ruma::{CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId}; use super::PduCount; -use crate::{service::rooms::timeline::PduId, PduEvent, Result}; +use crate::{PduEvent, Result, service::rooms::timeline::PduId}; pub(crate) trait Data: Send + Sync { /// Returns the `count` of this pdu's id. diff --git a/src/service/rooms/user/data.rs b/src/service/rooms/user/data.rs index d948e3e0..d9608f46 100644 --- a/src/service/rooms/user/data.rs +++ b/src/service/rooms/user/data.rs @@ -1,6 +1,6 @@ use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId}; -use crate::{service::rooms::short::ShortStateHash, Result}; +use crate::{Result, service::rooms::short::ShortStateHash}; pub(crate) trait Data: Send + Sync { fn reset_notification_counts( diff --git a/src/service/sending.rs b/src/service/sending.rs index 1c3b6ecb..9954d7d3 100644 --- a/src/service/sending.rs +++ b/src/service/sending.rs @@ -5,11 +5,14 @@ use std::{ time::{Duration, Instant}, }; -use base64::{engine::general_purpose, Engine as _}; +use base64::{Engine as _, engine::general_purpose}; use federation::transactions::send_transaction_message; -use futures_util::{stream::FuturesUnordered, StreamExt}; +use futures_util::{StreamExt, stream::FuturesUnordered}; use ruma::{ + MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedUserId, ServerName, UInt, + UserId, api::{ + OutgoingRequest, appservice::{self, Registration}, federation::{ self, @@ -18,33 +21,31 @@ use ruma::{ ReceiptMap, }, }, - OutgoingRequest, }, device_id, events::{ - push_rules::PushRulesEvent, receipt::ReceiptType, AnySyncEphemeralRoomEvent, GlobalAccountDataEventType, + push_rules::PushRulesEvent, receipt::ReceiptType, }, push, serde::Raw, - uint, MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedUserId, ServerName, - UInt, UserId, + uint, }; use tokio::{ select, - sync::{mpsc, Mutex, Semaphore}, + sync::{Mutex, Semaphore, mpsc}, }; -use tracing::{debug, error, warn, Span}; +use tracing::{Span, debug, error, warn}; use super::rooms::timeline::PduId; use crate::{ + Config, Error, PduEvent, Result, api::{ appservice_server, server_server::{self, AllowLoopbackRequests, LogRequestError}, }, services, utils::{calculate_hash, debug_slice_truncated}, - Config, Error, PduEvent, Result, }; mod data; diff --git a/src/service/uiaa.rs b/src/service/uiaa.rs index 566db934..073bc34f 100644 --- a/src/service/uiaa.rs +++ b/src/service/uiaa.rs @@ -1,16 +1,16 @@ use std::{collections::BTreeMap, sync::RwLock}; use ruma::{ + CanonicalJsonValue, DeviceId, OwnedDeviceId, OwnedUserId, UserId, api::client::{ error::ErrorKind, uiaa::{AuthData, AuthType, Password, UiaaInfo, UserIdentifier}, }, - CanonicalJsonValue, DeviceId, OwnedDeviceId, OwnedUserId, UserId, }; use tracing::error; use crate::{ - api::client_server::SESSION_ID_LENGTH, services, utils, Error, Result, + Error, Result, api::client_server::SESSION_ID_LENGTH, services, utils, }; mod data; diff --git a/src/service/uiaa/data.rs b/src/service/uiaa/data.rs index 2af82e11..ec814581 100644 --- a/src/service/uiaa/data.rs +++ b/src/service/uiaa/data.rs @@ -1,4 +1,4 @@ -use ruma::{api::client::uiaa::UiaaInfo, DeviceId, UserId}; +use ruma::{DeviceId, UserId, api::client::uiaa::UiaaInfo}; use crate::Result; diff --git a/src/service/users.rs b/src/service/users.rs index 3ee47386..474a7ffb 100644 --- a/src/service/users.rs +++ b/src/service/users.rs @@ -5,6 +5,8 @@ use std::{ }; use ruma::{ + DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId, + OwnedMxcUri, OwnedOneTimeKeyId, OwnedRoomId, OwnedUserId, UInt, UserId, api::client::{ device::Device, filter::FilterDefinition, @@ -16,11 +18,9 @@ use ruma::{ encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, events::AnyToDeviceEvent, serde::Raw, - DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId, - OwnedMxcUri, OwnedOneTimeKeyId, OwnedRoomId, OwnedUserId, UInt, UserId, }; -use crate::{services, Error, Result}; +use crate::{Error, Result, services}; mod data; diff --git a/src/service/users/data.rs b/src/service/users/data.rs index 630ded7d..901629cc 100644 --- a/src/service/users/data.rs +++ b/src/service/users/data.rs @@ -1,12 +1,12 @@ use std::collections::BTreeMap; use ruma::{ + DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId, + OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId, UInt, UserId, api::client::{device::Device, filter::FilterDefinition}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, events::AnyToDeviceEvent, serde::Raw, - DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId, - OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId, UInt, UserId, }; use crate::Result; @@ -29,7 +29,7 @@ pub(crate) trait Data: Send + Sync { /// Returns an iterator over all users on this homeserver. fn iter<'a>(&'a self) - -> Box> + 'a>; + -> Box> + 'a>; /// Returns a list of local users as list of usernames. /// diff --git a/src/utils.rs b/src/utils.rs index 45211399..8511a2d9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -6,13 +6,13 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use argon2::{password_hash, Argon2, PasswordHasher, PasswordVerifier}; +use argon2::{Argon2, PasswordHasher, PasswordVerifier, password_hash}; use cmp::Ordering; use rand::{prelude::*, rngs::OsRng}; use ring::digest; use ruma::{ - api::client::error::ErrorKind, canonical_json::try_from_json_map, CanonicalJsonError, CanonicalJsonObject, MxcUri, MxcUriError, OwnedMxcUri, + api::client::error::ErrorKind, canonical_json::try_from_json_map, }; use crate::{Error, Result}; diff --git a/src/utils/error.rs b/src/utils/error.rs index 49b5ab15..c8680cf0 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -2,11 +2,11 @@ use std::convert::Infallible; use http::StatusCode; use ruma::{ + OwnedServerName, api::client::{ error::{Error as RumaError, ErrorBody, ErrorKind}, uiaa::{UiaaInfo, UiaaResponse}, }, - OwnedServerName, }; use thiserror::Error; use tracing::{error, warn}; diff --git a/src/utils/on_demand_hashmap.rs b/src/utils/on_demand_hashmap.rs index 69e8bac9..ff3519e7 100644 --- a/src/utils/on_demand_hashmap.rs +++ b/src/utils/on_demand_hashmap.rs @@ -7,8 +7,8 @@ use std::{ sync::{Arc, Weak}, }; -use tokio::sync::{mpsc, Mutex, OwnedMutexGuard, RwLock}; -use tracing::{trace, warn, Level}; +use tokio::sync::{Mutex, OwnedMutexGuard, RwLock, mpsc}; +use tracing::{Level, trace, warn}; use crate::observability::METRICS; diff --git a/src/utils/proxy_protocol.rs b/src/utils/proxy_protocol.rs index 53021755..516e9b57 100644 --- a/src/utils/proxy_protocol.rs +++ b/src/utils/proxy_protocol.rs @@ -2,13 +2,13 @@ use std::{ future::Future, io::ErrorKind, pin::Pin, task::Poll, time::Duration, }; -use axum::{middleware::AddExtension, Extension}; +use axum::{Extension, middleware::AddExtension}; use axum_server::accept::Accept; use pin_project_lite::pin_project; -use proxy_header::{io::ProxiedStream, ParseConfig, ProxyHeader}; +use proxy_header::{ParseConfig, ProxyHeader, io::ProxiedStream}; use tokio::{ io::AsyncRead, - time::{timeout, Timeout}, + time::{Timeout, timeout}, }; use tower::Layer; use tracing::warn;