remove various unnecessary qualifications

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-08 09:25:47 -05:00 committed by June
parent aedb5966fe
commit 7c1624931d
17 changed files with 39 additions and 42 deletions

View file

@ -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
},

View file

@ -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<Option<Box<serde_json::value::RawValue>>> {
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<HashMap<RoomAccountDataEventType, Raw<AnyEphemeralRoomEvent>>> {
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);

View file

@ -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

View file

@ -122,11 +122,11 @@ impl service::media::Data for KeyValueDatabase {
let mut value = Vec::<u8>::new();
value.extend_from_slice(&timestamp.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);

View file

@ -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(

View file

@ -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::<PushRulesEvent>(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(