change rustfmt configuration

This change is fully automated, except the `rustfmt.toml` changes and
a few clippy directives to allow specific functions with too many lines
because they are longer now.
This commit is contained in:
Charles Hall 2024-05-16 01:19:04 -07:00
parent 40d6ce230d
commit 0afc1d2f50
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
123 changed files with 7881 additions and 4687 deletions

View file

@ -1,5 +1,8 @@
use ruma::{
events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId,
};
use crate::Result;
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
pub(crate) trait Data: Send + Sync {
/// Replaces the previous read receipt.
@ -10,7 +13,8 @@ pub(crate) trait Data: Send + Sync {
event: ReceiptEvent,
) -> Result<()>;
/// Returns an iterator over the most recent read receipts in a room that happened after the event with id `since`.
/// Returns an iterator over the most recent read receipts in a room that
/// happened after the event with id `since`.
#[allow(clippy::type_complexity)]
fn readreceipts_since<'a>(
&'a self,
@ -27,11 +31,24 @@ pub(crate) trait Data: Send + Sync {
>;
/// Sets a private read marker at `count`.
fn private_read_set(&self, room_id: &RoomId, user_id: &UserId, count: u64) -> Result<()>;
fn private_read_set(
&self,
room_id: &RoomId,
user_id: &UserId,
count: u64,
) -> Result<()>;
/// Returns the private read marker.
fn private_read_get(&self, room_id: &RoomId, user_id: &UserId) -> Result<Option<u64>>;
fn private_read_get(
&self,
room_id: &RoomId,
user_id: &UserId,
) -> Result<Option<u64>>;
/// Returns the count of the last typing update in this room.
fn last_privateread_update(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64>;
fn last_privateread_update(
&self,
user_id: &UserId,
room_id: &RoomId,
) -> Result<u64>;
}

View file

@ -1,8 +1,9 @@
use std::collections::BTreeMap;
use ruma::{
events::{typing::TypingEventContent, SyncEphemeralRoomEvent},
OwnedRoomId, OwnedUserId, RoomId, UserId,
};
use std::collections::BTreeMap;
use tokio::sync::{broadcast, RwLock};
use tracing::trace;
@ -10,15 +11,16 @@ use crate::{services, utils, Result};
pub(crate) struct Service {
// u64 is unix timestamp of timeout
pub(crate) typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
pub(crate) typing:
RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
// timestamp of the last change to typing users
pub(crate) last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>,
pub(crate) typing_update_sender: broadcast::Sender<OwnedRoomId>,
}
impl Service {
/// Sets a user as typing until the timeout timestamp is reached or `roomtyping_remove` is
/// called.
/// Sets a user as typing until the timeout timestamp is reached or
/// `roomtyping_remove` is called.
pub(crate) async fn typing_add(
&self,
user_id: &UserId,
@ -36,13 +38,20 @@ impl Service {
.await
.insert(room_id.to_owned(), services().globals.next_count()?);
if self.typing_update_sender.send(room_id.to_owned()).is_err() {
trace!("receiver found what it was looking for and is no longer interested");
trace!(
"receiver found what it was looking for and is no longer \
interested"
);
}
Ok(())
}
/// Removes a user from typing before the timeout is reached.
pub(crate) async fn typing_remove(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
pub(crate) async fn typing_remove(
&self,
user_id: &UserId,
room_id: &RoomId,
) -> Result<()> {
self.typing
.write()
.await
@ -54,7 +63,10 @@ impl Service {
.await
.insert(room_id.to_owned(), services().globals.next_count()?);
if self.typing_update_sender.send(room_id.to_owned()).is_err() {
trace!("receiver found what it was looking for and is no longer interested");
trace!(
"receiver found what it was looking for and is no longer \
interested"
);
}
Ok(())
}
@ -97,14 +109,20 @@ impl Service {
.await
.insert(room_id.to_owned(), services().globals.next_count()?);
if self.typing_update_sender.send(room_id.to_owned()).is_err() {
trace!("receiver found what it was looking for and is no longer interested");
trace!(
"receiver found what it was looking for and is no longer \
interested"
);
}
}
Ok(())
}
/// Returns the count of the last typing update in this room.
pub(crate) async fn last_typing_update(&self, room_id: &RoomId) -> Result<u64> {
pub(crate) async fn last_typing_update(
&self,
room_id: &RoomId,
) -> Result<u64> {
self.typings_maintain(room_id).await?;
Ok(self
.last_typing_update