Skip to content

Commit

Permalink
Fixes recommended by clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam committed Feb 21, 2024
1 parent 66c6ddf commit 9e5aa6d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/libolm_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn libolm_pickled_session_to_rust_pickled_session(
libolm_session: PickledSession,
pickle_key: &[u8],
) -> Result<matrix_sdk_crypto::olm::PickledSession> {
let session = vodozemac::olm::Session::from_libolm_pickle(&libolm_session.pickle, &pickle_key)?;
let session = vodozemac::olm::Session::from_libolm_pickle(&libolm_session.pickle, pickle_key)?;

let creation_time = date_to_seconds_since_epoch(&libolm_session.creation_time)
.ok_or_else(|| JsError::new("session creation time out of range"))?;
Expand Down Expand Up @@ -462,5 +462,5 @@ async fn import_megolm_sessions_to_store(
fn date_to_seconds_since_epoch(date: &Date) -> Option<SecondsSinceUnixEpoch> {
// javascript Dates are defined to be in milliseconds since the epoch
let duration_since_epoch = Duration::from_millis(date.get_time() as u64);
return Some(SecondsSinceUnixEpoch(UInt::new(duration_since_epoch.as_secs())?));
Some(SecondsSinceUnixEpoch(UInt::new(duration_since_epoch.as_secs())?))
}
10 changes: 5 additions & 5 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ impl OlmMachine {
let room_event = me
.decrypt_room_event(&event, room_id.as_ref())
.await
.map_err(|e| MegolmDecryptionError::from(e))?;
.map_err(MegolmDecryptionError::from)?;
Ok(responses::DecryptedRoomEvent::from(room_event))
}))
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ impl OlmMachine {
{
keys.entry(room_id.clone()).or_default().insert(session_id.into(), key);
} else {
failures = failures + 1;
failures += 1;
}
}
}
Expand Down Expand Up @@ -1423,7 +1423,7 @@ impl OlmMachine {
room_id: &identifiers::RoomId,
) -> Result<JsValue, JsError> {
let result = self.inner.room_settings(&room_id.inner).await?;
Ok(result.map(|settings| RoomSettings::from(settings)).into())
Ok(result.map(RoomSettings::from).into())
}

/// Store encryption settings for the given room.
Expand Down Expand Up @@ -1542,8 +1542,8 @@ async fn send_device_updates_to_callback(
async fn send_secret_gossip_to_callback(callback: &Function, secret: &GossippedSecret) {
match promise_result_to_future(callback.call2(
&JsValue::NULL,
&(secret.secret_name.as_str().into()),
&(&secret.event.content.secret.to_owned().into()),
&secret.secret_name.as_str().into(),
&secret.event.content.secret.to_owned().into(),
))
.await
{
Expand Down
6 changes: 3 additions & 3 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ impl StoreHandle {
}

async fn open_indexeddb(
store_name: &String,
store_name: &str,
store_passphrase: Option<String>,
) -> Result<Arc<DynCryptoStore>, matrix_sdk_indexeddb::IndexeddbCryptoStoreError> {
let store = match store_passphrase {
Some(mut store_passphrase) => {
use zeroize::Zeroize;

let store = matrix_sdk_indexeddb::IndexeddbCryptoStore::open_with_passphrase(
&store_name,
store_name,
&store_passphrase,
)
.await?;
Expand All @@ -90,7 +90,7 @@ impl StoreHandle {
store
}

None => matrix_sdk_indexeddb::IndexeddbCryptoStore::open_with_name(&store_name).await?,
None => matrix_sdk_indexeddb::IndexeddbCryptoStore::open_with_name(store_name).await?,
};

Ok(store.into_crypto_store())
Expand Down
8 changes: 2 additions & 6 deletions src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,7 @@ impl VerificationRequest {
pub fn their_supported_methods(&self) -> Result<Option<Vec<VerificationMethod>>, JsError> {
self.inner
.their_supported_methods()
.map(|methods| {
methods.into_iter().map(|method| VerificationMethod::try_from(method)).collect()
})
.map(|methods| methods.into_iter().map(VerificationMethod::try_from).collect())
.transpose()
}

Expand All @@ -872,9 +870,7 @@ impl VerificationRequest {
pub fn our_supported_methods(&self) -> Result<Option<Vec<VerificationMethod>>, JsError> {
self.inner
.our_supported_methods()
.map(|methods| {
methods.into_iter().map(|method| VerificationMethod::try_from(method)).collect()
})
.map(|methods| methods.into_iter().map(VerificationMethod::try_from).collect())
.transpose()
}

Expand Down

0 comments on commit 9e5aa6d

Please sign in to comment.