From 9fba91673ca8cfb3d3c060ad8d9e6fad58d31977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 21 Nov 2025 09:36:53 +0100 Subject: [PATCH 1/2] Update to Rust 2024 edition --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e6a3b1f..e3bbbfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://ruma.dev/" keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" repository = "https://github.com/ruma/synapse-admin-api" -edition = "2021" +edition = "2024" rust-version = "1.88" [features] From 0d8b38513e59b2b3b5ca7603a18d94bbe6677ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 21 Nov 2025 09:37:07 +0100 Subject: [PATCH 2/2] Run rustfmt --- src/account_validity/renew_account/v1.rs | 2 +- src/background_updates/status/v1.rs | 5 ++++- src/experimental_features/enable_features/v1.rs | 3 ++- src/experimental_features/list_features/v1.rs | 3 ++- src/register_users/shared_secret_register/v1.rs | 12 +++--------- src/room_membership/join_room/v1.rs | 3 ++- src/rooms/list_rooms/v1.rs | 3 ++- src/rooms/room_details/v1.rs | 3 ++- src/rooms/room_members/v1.rs | 2 +- src/serde.rs | 2 +- src/users.rs | 2 +- src/users/create_or_modify/v2.rs | 2 +- src/users/deactivate_account/v1.rs | 2 +- src/users/get_details/v2.rs | 2 +- src/users/is_user_admin/v1.rs | 2 +- src/users/list_joined_rooms/v1.rs | 2 +- src/users/list_users/v2.rs | 2 +- src/users/reset_password/v1.rs | 2 +- 18 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/account_validity/renew_account/v1.rs b/src/account_validity/renew_account/v1.rs index d1d7ed9..01b6307 100644 --- a/src/account_validity/renew_account/v1.rs +++ b/src/account_validity/renew_account/v1.rs @@ -1,8 +1,8 @@ //! [GET /_synapse/admin/v1/account_validity/validity](https://github.com/element-hq/synapse/blob/master/docs/admin_api/account_validity.md) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, MilliSecondsSinceUnixEpoch, OwnedUserId, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! { diff --git a/src/background_updates/status/v1.rs b/src/background_updates/status/v1.rs index bfcec2e..69c6554 100644 --- a/src/background_updates/status/v1.rs +++ b/src/background_updates/status/v1.rs @@ -115,7 +115,10 @@ fn test_status_background_updates() { // Serialize let serialized = serde_json::to_string(&response).expect("Failed to serialize"); - assert_eq!(serialized, "{\"enabled\":true,\"current_updates\":{\"master\":{\"name\":\"current update 1\",\"total_item_count\":123456789,\"total_duration_ms\":2134567.12345,\"average_items_per_ms\":2.5}}}"); + assert_eq!( + serialized, + "{\"enabled\":true,\"current_updates\":{\"master\":{\"name\":\"current update 1\",\"total_item_count\":123456789,\"total_duration_ms\":2134567.12345,\"average_items_per_ms\":2.5}}}" + ); // Deserialize let deserialized: Response = serde_json::from_str(&serialized).expect("Failed to deserialize"); diff --git a/src/experimental_features/enable_features/v1.rs b/src/experimental_features/enable_features/v1.rs index 578ff25..5f1cdaf 100644 --- a/src/experimental_features/enable_features/v1.rs +++ b/src/experimental_features/enable_features/v1.rs @@ -1,8 +1,9 @@ //! [PUT /_synapse/admin/v1/experimental_features/:user_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/experimental_features.md#enablingdisabling-features) use ruma::{ + OwnedUserId, api::{auth_scheme::AccessToken, request, response}, - metadata, OwnedUserId, + metadata, }; use serde::{Deserialize, Serialize}; diff --git a/src/experimental_features/list_features/v1.rs b/src/experimental_features/list_features/v1.rs index 3a37e4b..308d826 100644 --- a/src/experimental_features/list_features/v1.rs +++ b/src/experimental_features/list_features/v1.rs @@ -1,8 +1,9 @@ //! [GET /_synapse/admin/v1/experimental_features/:user_id](https://github.com/element-hq/synapse/blob/develop/docs/admin_api/experimental_features.md#listing-enabled-features) use ruma::{ + OwnedUserId, api::{auth_scheme::AccessToken, request, response}, - metadata, OwnedUserId, + metadata, }; use serde::{Deserialize, Serialize}; diff --git a/src/register_users/shared_secret_register/v1.rs b/src/register_users/shared_secret_register/v1.rs index 0d93a16..4a05f43 100644 --- a/src/register_users/shared_secret_register/v1.rs +++ b/src/register_users/shared_secret_register/v1.rs @@ -1,10 +1,10 @@ //! [POST /_synapse/admin/v1/register](https://github.com/element-hq/synapse/blob/master/docs/admin_api/register_api.md) #[cfg(feature = "shared-secret-registration-mac")] -use hmac::{digest::InvalidLength, Hmac, Mac}; +use hmac::{Hmac, Mac, digest::InvalidLength}; use ruma::{ - api::{auth_scheme::NoAuthentication, metadata, request, response}, OwnedDeviceId, OwnedServerName, OwnedUserId, + api::{auth_scheme::NoAuthentication, metadata, request, response}, }; #[cfg(feature = "shared-secret-registration-mac")] use sha1::Sha1; @@ -103,13 +103,7 @@ pub fn hmac( mac.update(b"\x00"); mac.update(password.as_bytes()); mac.update(b"\x00"); - mac.update({ - if admin { - b"admin" - } else { - b"notadmin" - } - }); + mac.update(if admin { b"admin" } else { b"notadmin" }); let mac = mac.finalize(); let mac = hex::encode(mac.into_bytes()); diff --git a/src/room_membership/join_room/v1.rs b/src/room_membership/join_room/v1.rs index b947b65..ef1cd7a 100644 --- a/src/room_membership/join_room/v1.rs +++ b/src/room_membership/join_room/v1.rs @@ -1,8 +1,9 @@ //! [POST /_synapse/admin/v1/join/:room_id_or_alias](https://github.com/element-hq/synapse/blob/master/docs/admin_api/room_membership.md) use ruma::{ + OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, api::{auth_scheme::AccessToken, request, response}, - metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, + metadata, }; metadata! { diff --git a/src/rooms/list_rooms/v1.rs b/src/rooms/list_rooms/v1.rs index 6a44664..86b1108 100644 --- a/src/rooms/list_rooms/v1.rs +++ b/src/rooms/list_rooms/v1.rs @@ -1,10 +1,11 @@ //! [GET /_synapse/admin/v1/rooms](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#list-room-api) use ruma::{ + OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UInt, api::{auth_scheme::AccessToken, metadata, request, response}, events::room::{guest_access::GuestAccess, history_visibility::HistoryVisibility}, room::{JoinRuleKind, RoomType}, serde::StringEnum, - uint, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UInt, + uint, }; use serde::{Deserialize, Serialize}; diff --git a/src/rooms/room_details/v1.rs b/src/rooms/room_details/v1.rs index fd13c65..34e3884 100644 --- a/src/rooms/room_details/v1.rs +++ b/src/rooms/room_details/v1.rs @@ -1,9 +1,10 @@ //! [GET /_synapse/admin/v1/rooms/:room_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#room-details-api) use ruma::{ + OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UInt, api::{auth_scheme::AccessToken, metadata, request, response}, events::room::{guest_access::GuestAccess, history_visibility::HistoryVisibility}, room::{JoinRuleKind, RoomType}, - uint, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UInt, + uint, }; metadata! { diff --git a/src/rooms/room_members/v1.rs b/src/rooms/room_members/v1.rs index d484d2d..edece3e 100644 --- a/src/rooms/room_members/v1.rs +++ b/src/rooms/room_members/v1.rs @@ -1,7 +1,7 @@ //! [GET /_synapse/admin/v1/rooms/:room_id/members](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#room-members-api) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedRoomId, OwnedUserId, UInt, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! { diff --git a/src/serde.rs b/src/serde.rs index dcd49da..3f74109 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -1,6 +1,6 @@ //! synapse admin api specific serde -use serde::{de::Visitor, Deserializer}; +use serde::{Deserializer, de::Visitor}; pub(crate) fn bool_or_uint<'de, D>(deserializer: D) -> Result where diff --git a/src/users.rs b/src/users.rs index f65ed9e..88cdf15 100644 --- a/src/users.rs +++ b/src/users.rs @@ -8,7 +8,7 @@ pub mod list_joined_rooms; pub mod list_users; pub mod reset_password; -use ruma::{thirdparty::ThirdPartyIdentifier, SecondsSinceUnixEpoch}; +use ruma::{SecondsSinceUnixEpoch, thirdparty::ThirdPartyIdentifier}; use serde::{Deserialize, Serialize}; /// User details diff --git a/src/users/create_or_modify/v2.rs b/src/users/create_or_modify/v2.rs index d84422c..c72804e 100644 --- a/src/users/create_or_modify/v2.rs +++ b/src/users/create_or_modify/v2.rs @@ -1,9 +1,9 @@ //! [PUT /_synapse/admin/v2/users/:user_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#create-or-modify-account) use ruma::{ + OwnedUserId, api::{auth_scheme::AccessToken, metadata, request, response}, thirdparty::Medium, - OwnedUserId, }; use serde::{Deserialize, Serialize}; diff --git a/src/users/deactivate_account/v1.rs b/src/users/deactivate_account/v1.rs index 21f90d1..608bcde 100644 --- a/src/users/deactivate_account/v1.rs +++ b/src/users/deactivate_account/v1.rs @@ -1,8 +1,8 @@ //! [POST /_synapse/admin/v1/deactivate/:user_id](https://github.com/element-hq/synapse/blob/develop/docs/admin_api/user_admin_api.md#deactivate-account) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedUserId, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! { diff --git a/src/users/get_details/v2.rs b/src/users/get_details/v2.rs index e990d02..ac29dbb 100644 --- a/src/users/get_details/v2.rs +++ b/src/users/get_details/v2.rs @@ -1,8 +1,8 @@ //! [GET /_synapse/admin/v2/users/:user_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#query-user-account) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedUserId, + api::{auth_scheme::AccessToken, metadata, request, response}, }; pub use crate::users::UserDetails; diff --git a/src/users/is_user_admin/v1.rs b/src/users/is_user_admin/v1.rs index 8598071..c3f8f7e 100644 --- a/src/users/is_user_admin/v1.rs +++ b/src/users/is_user_admin/v1.rs @@ -1,8 +1,8 @@ //! [GET /_synapse/admin/v1/users/:user_id/admin](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#get-whether-a-user-is-a-server-administrator-or-not) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedUserId, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! { diff --git a/src/users/list_joined_rooms/v1.rs b/src/users/list_joined_rooms/v1.rs index 35c4d67..06a89b2 100644 --- a/src/users/list_joined_rooms/v1.rs +++ b/src/users/list_joined_rooms/v1.rs @@ -1,8 +1,8 @@ //! [GET /_synapse/admin/v1/users/:user_id/joined_rooms](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#list-joined-rooms-of-a-user) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedRoomId, OwnedUserId, UInt, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! { diff --git a/src/users/list_users/v2.rs b/src/users/list_users/v2.rs index 948a997..3fc72fe 100644 --- a/src/users/list_users/v2.rs +++ b/src/users/list_users/v2.rs @@ -1,8 +1,8 @@ //! [GET /_synapse/admin/v2/users](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#list-accounts) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedUserId, UInt, + api::{auth_scheme::AccessToken, metadata, request, response}, }; use serde::{Deserialize, Serialize}; diff --git a/src/users/reset_password/v1.rs b/src/users/reset_password/v1.rs index ff47f6f..3111330 100644 --- a/src/users/reset_password/v1.rs +++ b/src/users/reset_password/v1.rs @@ -1,8 +1,8 @@ //! [POST /_synapse/admin/v1/reset_password/:user_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/user_admin_api.md#reset-password) use ruma::{ - api::{auth_scheme::AccessToken, metadata, request, response}, OwnedUserId, + api::{auth_scheme::AccessToken, metadata, request, response}, }; metadata! {