rust-sdk: Remove a bunch of unused imports and unused variables.

master
Damir Jelić 2020-04-03 12:34:05 +02:00
parent 2e1add049d
commit 12dc5212e3
9 changed files with 26 additions and 50 deletions

View File

@ -20,8 +20,7 @@ use std::result::Result as StdResult;
use std::sync::Arc; use std::sync::Arc;
use super::error::{OlmError, Result, SignatureError, VerificationResult}; use super::error::{OlmError, Result, SignatureError, VerificationResult};
use super::memory_stores::SessionStore; use super::olm::{Account, InboundGroupSession};
use super::olm::{Account, InboundGroupSession, Session};
use super::store::memorystore::MemoryStore; use super::store::memorystore::MemoryStore;
#[cfg(feature = "sqlite-cryptostore")] #[cfg(feature = "sqlite-cryptostore")]
use super::store::sqlite::SqliteStore; use super::store::sqlite::SqliteStore;
@ -364,15 +363,16 @@ impl OlmMachine {
continue; continue;
} }
let curve_key_id = // let curve_key_id =
AlgorithmAndDeviceId(KeyAlgorithm::Curve25519, device_id.to_owned()); // AlgorithmAndDeviceId(KeyAlgorithm::Curve25519, device_id.to_owned());
let ed_key_id = AlgorithmAndDeviceId(KeyAlgorithm::Ed25519, device_id.to_owned()); let ed_key_id = AlgorithmAndDeviceId(KeyAlgorithm::Ed25519, device_id.to_owned());
let sender_key = if let Some(k) = device_keys.keys.get(&curve_key_id) { // TODO check if the curve key changed for an existing device.
k // let sender_key = if let Some(k) = device_keys.keys.get(&curve_key_id) {
} else { // k
continue; // } else {
}; // continue;
// };
let signing_key = if let Some(k) = device_keys.keys.get(&ed_key_id) { let signing_key = if let Some(k) = device_keys.keys.get(&ed_key_id) {
k k
@ -397,7 +397,7 @@ impl OlmMachine {
.await .await
.expect("Can't load device"); .expect("Can't load device");
if let Some(d) = device { if let Some(_d) = device {
// TODO check what and if anything changed for the device. // TODO check what and if anything changed for the device.
} else { } else {
let device = Device::from(device_keys); let device = Device::from(device_keys);
@ -412,7 +412,7 @@ impl OlmMachine {
let deleted_devices = stored_devices_set.difference(&current_devices); let deleted_devices = stored_devices_set.difference(&current_devices);
for device_id in deleted_devices { for _device_id in deleted_devices {
// TODO delete devices here. // TODO delete devices here.
} }
} }
@ -680,7 +680,7 @@ impl OlmMachine {
async fn decrypt_olm_message( async fn decrypt_olm_message(
&mut self, &mut self,
sender: &str, _sender: &str,
sender_key: &str, sender_key: &str,
message: OlmMessage, message: OlmMessage,
) -> Result<EventResult<ToDeviceEvent>> { ) -> Result<EventResult<ToDeviceEvent>> {
@ -785,8 +785,8 @@ impl OlmMachine {
fn add_forwarded_room_key( fn add_forwarded_room_key(
&self, &self,
sender_key: &str, _sender_key: &str,
event: &ToDeviceForwardedRoomKey, _event: &ToDeviceForwardedRoomKey,
) -> Result<()> { ) -> Result<()> {
Ok(()) Ok(())
// TODO // TODO

View File

@ -40,7 +40,7 @@ impl SessionStore {
Arc::new(Mutex::new(Vec::new())), Arc::new(Mutex::new(Vec::new())),
); );
} }
let mut sessions = self.entries.get_mut(&session.sender_key).unwrap(); let sessions = self.entries.get_mut(&session.sender_key).unwrap();
let session = Arc::new(Mutex::new(session)); let session = Arc::new(Mutex::new(session));
sessions.lock().await.push(session.clone()); sessions.lock().await.push(session.clone());
@ -75,13 +75,13 @@ impl GroupSessionStore {
.insert(session.room_id.to_owned(), HashMap::new()); .insert(session.room_id.to_owned(), HashMap::new());
} }
let mut room_map = self.entries.get_mut(&session.room_id).unwrap(); let room_map = self.entries.get_mut(&session.room_id).unwrap();
if !room_map.contains_key(&session.sender_key) { if !room_map.contains_key(&session.sender_key) {
room_map.insert(session.sender_key.to_owned(), HashMap::new()); room_map.insert(session.sender_key.to_owned(), HashMap::new());
} }
let mut sender_map = room_map.get_mut(&session.sender_key).unwrap(); let sender_map = room_map.get_mut(&session.sender_key).unwrap();
let ret = sender_map.insert(session.session_id(), Arc::new(Mutex::new(session))); let ret = sender_map.insert(session.session_id(), Arc::new(Mutex::new(session)));
ret.is_some() ret.is_some()
@ -134,7 +134,7 @@ impl DeviceStore {
self.entries self.entries
.insert(device.user_id().to_owned(), DashMap::new()); .insert(device.user_id().to_owned(), DashMap::new());
} }
let mut device_map = self.entries.get_mut(device.user_id()).unwrap(); let device_map = self.entries.get_mut(device.user_id()).unwrap();
device_map device_map
.insert(device.device_id().to_owned(), device) .insert(device.device_id().to_owned(), device)

View File

@ -259,7 +259,7 @@ impl InboundGroupSession {
self.inner.first_known_index() self.inner.first_known_index()
} }
pub fn decrypt(&self, mut message: String) -> Result<(String, u32), OlmGroupSessionError> { pub fn decrypt(&self, message: String) -> Result<(String, u32), OlmGroupSessionError> {
self.inner.decrypt(message) self.inner.decrypt(message)
} }
} }

View File

@ -18,7 +18,7 @@ use std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use super::{Account, CryptoStore, CryptoStoreError, InboundGroupSession, Result, Session}; use super::{Account, CryptoStore, InboundGroupSession, Result, Session};
use crate::crypto::device::Device; use crate::crypto::device::Device;
use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
@ -47,11 +47,11 @@ impl CryptoStore for MemoryStore {
Ok(None) Ok(None)
} }
async fn save_account(&mut self, account: Arc<Mutex<Account>>) -> Result<()> { async fn save_account(&mut self, _: Arc<Mutex<Account>>) -> Result<()> {
Ok(()) Ok(())
} }
async fn save_session(&mut self, session: Arc<Mutex<Session>>) -> Result<()> { async fn save_session(&mut self, _: Arc<Mutex<Session>>) -> Result<()> {
Ok(()) Ok(())
} }

View File

@ -13,9 +13,8 @@
// limitations under the License. // limitations under the License.
use core::fmt::Debug; use core::fmt::Debug;
use std::collections::{HashMap, HashSet}; use std::collections::HashSet;
use std::io::Error as IoError; use std::io::Error as IoError;
use std::result::Result as StdResult;
use std::sync::Arc; use std::sync::Arc;
use url::ParseError; use url::ParseError;
@ -28,7 +27,6 @@ use super::device::Device;
use super::memory_stores::UserDevices; use super::memory_stores::UserDevices;
use super::olm::{Account, InboundGroupSession, Session}; use super::olm::{Account, InboundGroupSession, Session};
use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError};
use olm_rs::PicklingMode;
pub mod memorystore; pub mod memorystore;
#[cfg(feature = "sqlite-cryptostore")] #[cfg(feature = "sqlite-cryptostore")]

View File

@ -410,15 +410,15 @@ impl CryptoStore for SqliteStore {
Ok(self.tracked_users.insert(user.to_string())) Ok(self.tracked_users.insert(user.to_string()))
} }
async fn get_device(&self, user_id: &str, device_id: &str) -> Result<Option<Device>> { async fn get_device(&self, _user_id: &str, _device_id: &str) -> Result<Option<Device>> {
todo!() todo!()
} }
async fn get_user_devices(&self, user_id: &str) -> Result<UserDevices> { async fn get_user_devices(&self, _user_id: &str) -> Result<UserDevices> {
todo!() todo!()
} }
async fn save_device(&self, device: Device) -> Result<()> { async fn save_device(&self, _device: Device) -> Result<()> {
todo!() todo!()
} }
} }

View File

@ -31,14 +31,6 @@ use crate::identifiers::RoomAliasId;
use js_int::UInt; use js_int::UInt;
#[cfg(feature = "encryption")]
use tokio::sync::Mutex;
#[cfg(feature = "encryption")]
use crate::crypto::{OlmMachine, OneTimeKeys};
#[cfg(feature = "encryption")]
use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys};
#[derive(Debug, Default)] #[derive(Debug, Default)]
/// `RoomName` allows the calculation of a text room name. /// `RoomName` allows the calculation of a text room name.
pub struct RoomName { pub struct RoomName {

View File

@ -24,13 +24,6 @@ use crate::events::room::{
use crate::identifiers::UserId; use crate::identifiers::UserId;
use js_int::Int; use js_int::Int;
#[cfg(feature = "encryption")]
use tokio::sync::Mutex;
#[cfg(feature = "encryption")]
use crate::crypto::{OlmMachine, OneTimeKeys};
#[cfg(feature = "encryption")]
use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys};
// Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob. // Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob.

View File

@ -18,13 +18,6 @@ use crate::events::presence::{PresenceEvent, PresenceEventContent, PresenceState
use crate::events::room::member::MemberEvent; use crate::events::room::member::MemberEvent;
use js_int::UInt; use js_int::UInt;
#[cfg(feature = "encryption")]
use tokio::sync::Mutex;
#[cfg(feature = "encryption")]
use crate::crypto::{OlmMachine, OneTimeKeys};
#[cfg(feature = "encryption")]
use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys};
#[derive(Debug)] #[derive(Debug)]
/// A Matrix room member. /// A Matrix room member.