cargo fmt/clippy
parent
f2b50677b9
commit
5c418f3420
|
@ -1,6 +1,6 @@
|
||||||
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::{env, process::exit};
|
use std::{env, process::exit};
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::collections::HashMap;
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use futures::future::{BoxFuture, Future, FutureExt};
|
use futures::future::{BoxFuture, Future, FutureExt};
|
||||||
|
@ -263,13 +263,20 @@ impl AsyncClient {
|
||||||
/// Add `EventEmitter` to `AsyncClient`.
|
/// Add `EventEmitter` to `AsyncClient`.
|
||||||
///
|
///
|
||||||
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
||||||
pub async fn add_event_emitter(&mut self, emitter: Arc<tokio::sync::Mutex<Box<dyn EventEmitter>>>) {
|
pub async fn add_event_emitter(
|
||||||
|
&mut self,
|
||||||
|
emitter: Arc<tokio::sync::Mutex<Box<dyn EventEmitter>>>,
|
||||||
|
) {
|
||||||
self.base_client.write().await.event_emitter = Some(emitter);
|
self.base_client.write().await.event_emitter = Some(emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the room name from a `RoomId`, returning a string.
|
/// Calculates the room name from a `RoomId`, returning a string.
|
||||||
pub async fn get_room_name(&self, room_id: &str) -> Option<String> {
|
pub async fn get_room_name(&self, room_id: &str) -> Option<String> {
|
||||||
self.base_client.read().await.calculate_room_name(room_id).await
|
self.base_client
|
||||||
|
.read()
|
||||||
|
.await
|
||||||
|
.calculate_room_name(room_id)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the room names this client knows about.
|
/// Calculates the room names this client knows about.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
|
@ -302,10 +302,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut room = self
|
let mut room = self.get_or_create_room(&room_id.to_string()).lock().await;
|
||||||
.get_or_create_room(&room_id.to_string())
|
|
||||||
.lock()
|
|
||||||
.await;
|
|
||||||
room.receive_timeline_event(e);
|
room.receive_timeline_event(e);
|
||||||
decrypted_event
|
decrypted_event
|
||||||
}
|
}
|
||||||
|
@ -527,7 +524,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_room_canonical_alias(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_room_canonical_alias(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_room_message_feedback(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_room_message_feedback(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,7 +580,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_room_redaction(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_room_redaction(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,7 +593,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_room_power_levels(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_room_power_levels(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,7 +632,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_state_canonical_alias(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_state_canonical_alias(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -633,7 +645,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_state_aliases(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_state_aliases(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -653,7 +668,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_state_power_levels(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_state_power_levels(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -663,7 +681,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_state_join_rules(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_state_join_rules(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,7 +704,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_account_presence(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_account_presence(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -693,7 +717,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_account_ignored_users(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_account_ignored_users(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,7 +730,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_account_push_rules(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_account_push_rules(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,7 +743,10 @@ impl Client {
|
||||||
if let Some(room) = self.get_room(&room_id.to_string()) {
|
if let Some(room) = self.get_room(&room_id.to_string()) {
|
||||||
ee.lock()
|
ee.lock()
|
||||||
.await
|
.await
|
||||||
.on_account_data_fully_read(Arc::clone(&room), Arc::new(Mutex::new(event.clone())))
|
.on_account_data_fully_read(
|
||||||
|
Arc::clone(&room),
|
||||||
|
Arc::new(Mutex::new(event.clone())),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,17 @@ pub trait EventEmitter: Send + Sync {
|
||||||
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomMember` event.
|
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomMember` event.
|
||||||
async fn on_account_presence(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
async fn on_account_presence(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
||||||
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomName` event.
|
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomName` event.
|
||||||
async fn on_account_ignored_users(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
async fn on_account_ignored_users(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {
|
||||||
|
}
|
||||||
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomCanonicalAlias` event.
|
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomCanonicalAlias` event.
|
||||||
async fn on_account_push_rules(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
async fn on_account_push_rules(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
||||||
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomAliases` event.
|
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomAliases` event.
|
||||||
async fn on_account_data_fully_read(&mut self, _: Arc<Mutex<Room>>, _: Arc<Mutex<NonRoomEvent>>) {}
|
async fn on_account_data_fully_read(
|
||||||
|
&mut self,
|
||||||
|
_: Arc<Mutex<Room>>,
|
||||||
|
_: Arc<Mutex<NonRoomEvent>>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
// `PresenceEvent` is a struct so there is only the one method
|
// `PresenceEvent` is a struct so there is only the one method
|
||||||
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomAliases` event.
|
/// Fires when `AsyncClient` receives a `NonRoomEvent::RoomAliases` event.
|
||||||
|
|
Loading…
Reference in New Issue