diff --git a/src/api/appservice_server.rs b/src/api/appservice_server.rs index 73c4d12e..3d503a57 100644 --- a/src/api/appservice_server.rs +++ b/src/api/appservice_server.rs @@ -28,7 +28,7 @@ where Error::BadServerResponse("Invalid destination") }) .unwrap() - .map(bytes::BytesMut::freeze); + .map(BytesMut::freeze); let mut parts = http_request.uri().clone().into_parts(); let old_path_and_query = parts.path_and_query.unwrap().as_str().to_owned(); diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index ac5c9e11..6beb09d0 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -66,7 +66,7 @@ pub async fn join_room_by_id_route(body: Ruma) -> .iter() .filter_map(|event| serde_json::from_str(event.json().get()).ok()) .filter_map(|event: serde_json::Value| event.get("sender").cloned()) - .filter_map(|sender| sender.as_str().map(std::borrow::ToOwned::to_owned)) + .filter_map(|sender| sender.as_str().map(ToOwned::to_owned)) .filter_map(|sender| UserId::parse(sender).ok()) .map(|user| user.server_name().to_owned()), ); @@ -123,7 +123,7 @@ pub async fn join_room_by_id_or_alias_route( .iter() .filter_map(|event| serde_json::from_str(event.json().get()).ok()) .filter_map(|event: serde_json::Value| event.get("sender").cloned()) - .filter_map(|sender| sender.as_str().map(std::borrow::ToOwned::to_owned)) + .filter_map(|sender| sender.as_str().map(ToOwned::to_owned)) .filter_map(|sender| UserId::parse(sender).ok()) .map(|user| user.server_name().to_owned()), ); @@ -1382,7 +1382,7 @@ async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> { .iter() .filter_map(|event| serde_json::from_str(event.json().get()).ok()) .filter_map(|event: serde_json::Value| event.get("sender").cloned()) - .filter_map(|sender| sender.as_str().map(std::borrow::ToOwned::to_owned)) + .filter_map(|sender| sender.as_str().map(ToOwned::to_owned)) .filter_map(|sender| UserId::parse(sender).ok()) .map(|user| user.server_name().to_owned()) .collect(); diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index 07a35fe5..8d179b48 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -262,7 +262,7 @@ where } }; - let mut http_request = http::Request::builder().uri(parts.uri).method(parts.method); + let mut http_request = Request::builder().uri(parts.uri).method(parts.method); *http_request.headers_mut().unwrap() = parts.headers; if let Some(CanonicalJsonValue::Object(json_body)) = &mut json_body { diff --git a/src/database/abstraction/watchers.rs b/src/database/abstraction/watchers.rs index bbb306b7..d85238b0 100644 --- a/src/database/abstraction/watchers.rs +++ b/src/database/abstraction/watchers.rs @@ -19,7 +19,7 @@ impl Watchers { let mut rx = match self.watchers.write().unwrap().entry(prefix.to_vec()) { hash_map::Entry::Occupied(o) => o.get().1.clone(), hash_map::Entry::Vacant(v) => { - let (tx, rx) = tokio::sync::watch::channel(()); + let (tx, rx) = watch::channel(()); v.insert((tx, rx.clone())); rx }, diff --git a/src/database/key_value/account_data.rs b/src/database/key_value/account_data.rs index 90b033fb..87455a66 100644 --- a/src/database/key_value/account_data.rs +++ b/src/database/key_value/account_data.rs @@ -18,7 +18,7 @@ impl service::account_data::Data for KeyValueDatabase { &self, room_id: Option<&RoomId>, user_id: &UserId, event_type: RoomAccountDataEventType, data: &serde_json::Value, ) -> Result<()> { - let mut prefix = room_id.map(std::string::ToString::to_string).unwrap_or_default().as_bytes().to_vec(); + let mut prefix = room_id.map(ToString::to_string).unwrap_or_default().as_bytes().to_vec(); prefix.push(0xFF); prefix.extend_from_slice(user_id.as_bytes()); prefix.push(0xFF); @@ -60,7 +60,7 @@ impl service::account_data::Data for KeyValueDatabase { fn get( &self, room_id: Option<&RoomId>, user_id: &UserId, kind: RoomAccountDataEventType, ) -> Result>> { - let mut key = room_id.map(std::string::ToString::to_string).unwrap_or_default().as_bytes().to_vec(); + let mut key = room_id.map(ToString::to_string).unwrap_or_default().as_bytes().to_vec(); key.push(0xFF); key.extend_from_slice(user_id.as_bytes()); key.push(0xFF); @@ -81,7 +81,7 @@ impl service::account_data::Data for KeyValueDatabase { ) -> Result>> { let mut userdata = HashMap::new(); - let mut prefix = room_id.map(std::string::ToString::to_string).unwrap_or_default().as_bytes().to_vec(); + let mut prefix = room_id.map(ToString::to_string).unwrap_or_default().as_bytes().to_vec(); prefix.push(0xFF); prefix.extend_from_slice(user_id.as_bytes()); prefix.push(0xFF); diff --git a/src/database/key_value/globals.rs b/src/database/key_value/globals.rs index 6c8e5b7d..02186a4e 100644 --- a/src/database/key_value/globals.rs +++ b/src/database/key_value/globals.rs @@ -62,7 +62,7 @@ impl service::globals::Data for KeyValueDatabase { futures.push(self.userroomid_highlightcount.watch_prefix(&userid_prefix)); // Events for rooms we are in - for room_id in services().rooms.state_cache.rooms_joined(user_id).filter_map(std::result::Result::ok) { + for room_id in services().rooms.state_cache.rooms_joined(user_id).filter_map(Result::ok) { let short_roomid = services() .rooms .short diff --git a/src/database/key_value/media.rs b/src/database/key_value/media.rs index 007ccdf2..f00f6b55 100644 --- a/src/database/key_value/media.rs +++ b/src/database/key_value/media.rs @@ -122,11 +122,11 @@ impl service::media::Data for KeyValueDatabase { let mut value = Vec::::new(); value.extend_from_slice(×tamp.as_secs().to_be_bytes()); value.push(0xFF); - value.extend_from_slice(data.title.as_ref().map(std::string::String::as_bytes).unwrap_or_default()); + value.extend_from_slice(data.title.as_ref().map(String::as_bytes).unwrap_or_default()); value.push(0xFF); - value.extend_from_slice(data.description.as_ref().map(std::string::String::as_bytes).unwrap_or_default()); + value.extend_from_slice(data.description.as_ref().map(String::as_bytes).unwrap_or_default()); value.push(0xFF); - value.extend_from_slice(data.image.as_ref().map(std::string::String::as_bytes).unwrap_or_default()); + value.extend_from_slice(data.image.as_ref().map(String::as_bytes).unwrap_or_default()); value.push(0xFF); value.extend_from_slice(&data.image_size.unwrap_or(0).to_be_bytes()); value.push(0xFF); diff --git a/src/database/key_value/uiaa.rs b/src/database/key_value/uiaa.rs index de200614..9ec364dc 100644 --- a/src/database/key_value/uiaa.rs +++ b/src/database/key_value/uiaa.rs @@ -22,7 +22,7 @@ impl service::uiaa::Data for KeyValueDatabase { .read() .unwrap() .get(&(user_id.to_owned(), device_id.to_owned(), session.to_owned())) - .map(std::borrow::ToOwned::to_owned) + .map(ToOwned::to_owned) } fn update_uiaa_session( diff --git a/src/database/mod.rs b/src/database/mod.rs index 4fc9b924..7222d1b0 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -229,7 +229,7 @@ impl KeyValueDatabase { if !Path::new(&config.database_path).exists() { debug!("Database path does not exist, assuming this is a new setup and creating it"); - std::fs::create_dir_all(&config.database_path).map_err(|e| { + fs::create_dir_all(&config.database_path).map_err(|e| { error!("Failed to create database path: {e}"); Error::BadConfig( "Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please \ @@ -864,7 +864,7 @@ impl KeyValueDatabase { let mut account_data = serde_json::from_str::(raw_rules_list.get()).unwrap(); - let user_default_rules = ruma::push::Ruleset::server_default(&user); + let user_default_rules = Ruleset::server_default(&user); account_data.content.global.update_with_server_default(user_default_rules); services().account_data.update( diff --git a/src/main.rs b/src/main.rs index 1b8a7179..ea88908e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -473,7 +473,7 @@ async fn run_server() -> io::Result<()> { } async fn spawn_task( - req: axum::http::Request, next: axum::middleware::Next, + req: http::Request, next: axum::middleware::Next, ) -> std::result::Result { if services().globals.shutdown.load(atomic::Ordering::Relaxed) { return Err(StatusCode::SERVICE_UNAVAILABLE); @@ -482,12 +482,12 @@ async fn spawn_task( } async fn unrecognized_method( - req: axum::http::Request, next: axum::middleware::Next, + req: http::Request, next: axum::middleware::Next, ) -> std::result::Result { let method = req.method().clone(); let uri = req.uri().clone(); let inner = next.run(req).await; - if inner.status() == axum::http::StatusCode::METHOD_NOT_ALLOWED { + if inner.status() == StatusCode::METHOD_NOT_ALLOWED { warn!("Method not allowed: {method} {uri}"); return Ok(RumaResponse(UiaaResponse::MatrixError(RumaError { body: ErrorBody::Standard { diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index fec27e1e..f7e27c38 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -609,9 +609,7 @@ impl Service { Err(_) => RoomMessageEventContent::text_plain("Failed to get appservice."), }, AppserviceCommand::List => { - if let Ok(appservices) = - services().appservice.iter_ids().map(std::iter::Iterator::collect::>) - { + if let Ok(appservices) = services().appservice.iter_ids().map(Iterator::collect::>) { let count = appservices.len(); let output = format!( "Appservices ({}): {}", diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index ec069588..a40514f4 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -469,7 +469,7 @@ impl Service<'_> { if self.unix_socket_path().is_some() { match &self.unix_socket_path() { Some(path) => { - std::fs::remove_file(path).unwrap(); + fs::remove_file(path).unwrap(); }, None => error!( "Unable to remove socket file at {:?} during shutdown.", diff --git a/src/service/media/mod.rs b/src/service/media/mod.rs index 97652a35..3677fe52 100644 --- a/src/service/media/mod.rs +++ b/src/service/media/mod.rs @@ -75,7 +75,7 @@ impl Service { debug!("Got local file path: {:?}", file_path); debug!("Deleting local file {:?} from filesystem, original MXC: {}", file_path, mxc); - tokio::fs::remove_file(file_path).await?; + fs::remove_file(file_path).await?; debug!("Deleting MXC {mxc} from database"); self.db.delete_file_mxc(mxc.clone())?; @@ -318,20 +318,20 @@ impl Service { u64::from(original_width) * u64::from(height) / u64::from(original_height) }; if use_width { - if intermediate <= u64::from(::std::u32::MAX) { + if intermediate <= u64::from(std::u32::MAX) { (width, intermediate as u32) } else { ( - (u64::from(width) * u64::from(::std::u32::MAX) / intermediate) as u32, - ::std::u32::MAX, + (u64::from(width) * u64::from(std::u32::MAX) / intermediate) as u32, + std::u32::MAX, ) } - } else if intermediate <= u64::from(::std::u32::MAX) { + } else if intermediate <= u64::from(std::u32::MAX) { (intermediate as u32, height) } else { ( - ::std::u32::MAX, - (u64::from(height) * u64::from(::std::u32::MAX) / intermediate) as u32, + std::u32::MAX, + (u64::from(height) * u64::from(std::u32::MAX) / intermediate) as u32, ) } }; diff --git a/src/service/pusher/mod.rs b/src/service/pusher/mod.rs index 79f61849..13abe52f 100644 --- a/src/service/pusher/mod.rs +++ b/src/service/pusher/mod.rs @@ -55,7 +55,7 @@ impl Service { warn!("Failed to find destination {}: {}", destination, e); Error::BadServerResponse("Invalid destination") })? - .map(bytes::BytesMut::freeze); + .map(BytesMut::freeze); let reqwest_request = reqwest::Request::try_from(http_request)?; diff --git a/src/service/rooms/event_handler/mod.rs b/src/service/rooms/event_handler/mod.rs index dbc19ebf..f0a12cb9 100644 --- a/src/service/rooms/event_handler/mod.rs +++ b/src/service/rooms/event_handler/mod.rs @@ -367,7 +367,7 @@ impl Service { // The original create event must be in the auth events if !matches!( - auth_events.get(&(StateEventType::RoomCreate, "".to_owned())).map(std::convert::AsRef::as_ref), + auth_events.get(&(StateEventType::RoomCreate, "".to_owned())).map(AsRef::as_ref), Some(_) | None ) { return Err(Error::BadRequest( @@ -623,8 +623,7 @@ impl Service { .get_shortstatekey(&StateEventType::RoomCreate, "")? .expect("Room exists"); - if state.get(&create_shortstatekey).map(std::convert::AsRef::as_ref) != Some(&create_event.event_id) - { + if state.get(&create_shortstatekey).map(AsRef::as_ref) != Some(&create_event.event_id) { return Err(Error::bad_database("Incoming event refers to wrong create event.")); } diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs index 51187f59..4e7ffcca 100644 --- a/src/service/rooms/spaces/mod.rs +++ b/src/service/rooms/spaces/mod.rs @@ -57,11 +57,11 @@ impl Service { let mut results = Vec::new(); while let Some(current_room) = { - while stack.last().map_or(false, std::vec::Vec::is_empty) { + while stack.last().map_or(false, Vec::is_empty) { stack.pop(); } if !stack.is_empty() { - stack.last_mut().and_then(std::vec::Vec::pop) + stack.last_mut().and_then(Vec::pop) } else { None } @@ -402,7 +402,7 @@ impl Service { match join_rule { JoinRule::Restricted(r) => { for rule in &r.allow { - if let join_rules::AllowRule::RoomMembership(rm) = rule { + if let AllowRule::RoomMembership(rm) = rule { if let Ok(true) = services().rooms.state_cache.is_joined(sender_user, &rm.room_id) { return Ok(true); } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index b6edede1..672224f6 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -19,7 +19,7 @@ pub(crate) fn millis_since_unix_epoch() -> u64 { } pub(crate) fn increment(old: Option<&[u8]>) -> Option> { - let number = match old.map(std::convert::TryInto::try_into) { + let number = match old.map(TryInto::try_into) { Some(Ok(bytes)) => { let number = u64::from_be_bytes(bytes); number + 1 @@ -80,7 +80,7 @@ pub(crate) fn common_elements( mut iterators: impl Iterator>>, check_order: impl Fn(&[u8], &[u8]) -> Ordering, ) -> Option>> { let first_iterator = iterators.next()?; - let mut other_iterators = iterators.map(std::iter::Iterator::peekable).collect::>(); + let mut other_iterators = iterators.map(Iterator::peekable).collect::>(); Some(first_iterator.filter(move |target| { other_iterators.iter_mut().all(|it| { @@ -112,14 +112,14 @@ pub(crate) fn to_canonical_object(value: T) -> Result, T: FromStr, E: std::fmt::Display>( +pub(crate) fn deserialize_from_str<'de, D: serde::de::Deserializer<'de>, T: FromStr, E: fmt::Display>( deserializer: D, ) -> Result { struct Visitor, E>(std::marker::PhantomData); - impl, Err: std::fmt::Display> serde::de::Visitor<'_> for Visitor { + impl, Err: fmt::Display> serde::de::Visitor<'_> for Visitor { type Value = T; - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "a parsable string") }