Skip to content

Commit 2d17386

Browse files
committed
chore(indexeddb): Run rustfmt.
1 parent c3e01a6 commit 2d17386

File tree

1 file changed

+29
-33
lines changed
  • crates/matrix-sdk-indexeddb/src/crypto_store

1 file changed

+29
-33
lines changed

crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use ruma::{
5151
events::secret::request::SecretName, DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId,
5252
RoomId, TransactionId, UserId,
5353
};
54+
use serde::{Deserialize, Serialize};
5455
use sha2::Sha256;
5556
use tokio::sync::Mutex;
5657
use tracing::{debug, warn};
@@ -772,9 +773,9 @@ macro_rules! impl_crypto_store {
772773

773774
impl_crypto_store! {
774775
async fn save_pending_changes(&self, changes: PendingChanges) -> Result<()> {
775-
// Serialize calls to `save_pending_changes`; there are multiple await points below, and we're
776-
// pickling data as we go, so we don't want to invalidate data we've previously read and
777-
// overwrite it in the store.
776+
// Serialize calls to `save_pending_changes`; there are multiple await points
777+
// below, and we're pickling data as we go, so we don't want to
778+
// invalidate data we've previously read and overwrite it in the store.
778779
// TODO: #2000 should make this lock go away, or change its shape.
779780
let _guard = self.save_changes_lock.lock().await;
780781

@@ -810,9 +811,9 @@ impl_crypto_store! {
810811
}
811812

812813
async fn save_changes(&self, changes: Changes) -> Result<()> {
813-
// Serialize calls to `save_changes`; there are multiple await points below, and we're
814-
// pickling data as we go, so we don't want to invalidate data we've previously read and
815-
// overwrite it in the store.
814+
// Serialize calls to `save_changes`; there are multiple await points below, and
815+
// we're pickling data as we go, so we don't want to invalidate data
816+
// we've previously read and overwrite it in the store.
816817
// TODO: #2000 should make this lock go away, or change its shape.
817818
let _guard = self.save_changes_lock.lock().await;
818819

@@ -1101,9 +1102,7 @@ impl_crypto_store! {
11011102
.collect();
11021103
let upper_bound: Array =
11031104
[sender_key, ((sender_data_type as u8) + 1).into()].iter().collect();
1104-
let key = KeyRange::Bound(
1105-
lower_bound, true,
1106-
upper_bound, true);
1105+
let key = KeyRange::Bound(lower_bound, true, upper_bound, true);
11071106

11081107
let tx = self
11091108
.inner
@@ -1162,8 +1161,8 @@ impl_crypto_store! {
11621161
let store = tx.object_store(keys::INBOUND_GROUP_SESSIONS_V3)?;
11631162
let idx = store.index(keys::INBOUND_GROUP_SESSIONS_BACKUP_INDEX)?;
11641163

1165-
// XXX ideally we would use `get_all_with_key_and_limit`, but that doesn't appear to be
1166-
// exposed (https://github.com/Alorel/rust-indexed-db/issues/31). Instead we replicate
1164+
// XXX ideally we would use `get_all_with_key_and_limit`, but that doesn't
1165+
// appear to be exposed (https://github.com/Alorel/rust-indexed-db/issues/31). Instead we replicate
11671166
// the behaviour with a cursor.
11681167
let Some(mut cursor) = idx.open_cursor().await? else {
11691168
return Ok(vec![]);
@@ -1332,7 +1331,9 @@ impl_crypto_store! {
13321331
.with_mode(TransactionMode::Readonly)
13331332
.build()?
13341333
.object_store(keys::OLM_HASHES)?
1335-
.get::<JsValue, _, _>(&self.serializer.encode_key(keys::OLM_HASHES, (&hash.sender_key, &hash.hash)))
1334+
.get::<JsValue, _, _>(
1335+
&self.serializer.encode_key(keys::OLM_HASHES, (&hash.sender_key, &hash.hash)),
1336+
)
13361337
.await?
13371338
.is_some())
13381339
}
@@ -1363,14 +1364,12 @@ impl_crypto_store! {
13631364
async fn delete_secrets_from_inbox(&self, secret_name: &SecretName) -> Result<()> {
13641365
let range = self.serializer.encode_to_range(keys::SECRETS_INBOX, secret_name.as_str());
13651366

1366-
let transaction = self.inner
1367+
let transaction = self
1368+
.inner
13671369
.transaction(keys::SECRETS_INBOX)
13681370
.with_mode(TransactionMode::Readwrite)
13691371
.build()?;
1370-
transaction
1371-
.object_store(keys::SECRETS_INBOX)?
1372-
.delete(&range)
1373-
.build()?;
1372+
transaction.object_store(keys::SECRETS_INBOX)?.delete(&range).build()?;
13741373
transaction.commit().await?;
13751374

13761375
Ok(())
@@ -1384,7 +1383,9 @@ impl_crypto_store! {
13841383

13851384
let val = self
13861385
.inner
1387-
.transaction(keys::GOSSIP_REQUESTS).with_mode( TransactionMode::Readonly).build()?
1386+
.transaction(keys::GOSSIP_REQUESTS)
1387+
.with_mode(TransactionMode::Readonly)
1388+
.build()?
13881389
.object_store(keys::GOSSIP_REQUESTS)?
13891390
.index(keys::GOSSIP_REQUESTS_BY_INFO_INDEX)?
13901391
.get(key)
@@ -1484,7 +1485,9 @@ impl_crypto_store! {
14841485
let key = self.serializer.encode_key(keys::DIRECT_WITHHELD_INFO, (session_id, room_id));
14851486
if let Some(pickle) = self
14861487
.inner
1487-
.transaction(keys::DIRECT_WITHHELD_INFO).with_mode( TransactionMode::Readonly).build()?
1488+
.transaction(keys::DIRECT_WITHHELD_INFO)
1489+
.with_mode(TransactionMode::Readonly)
1490+
.build()?
14881491
.object_store(keys::DIRECT_WITHHELD_INFO)?
14891492
.get(&key)
14901493
.await?
@@ -1543,10 +1546,8 @@ impl_crypto_store! {
15431546

15441547
#[allow(clippy::unused_async)] // Mandated by trait on wasm.
15451548
async fn set_custom_value(&self, key: &str, value: Vec<u8>) -> Result<()> {
1546-
let transaction = self.inner
1547-
.transaction(keys::CORE)
1548-
.with_mode(TransactionMode::Readwrite)
1549-
.build()?;
1549+
let transaction =
1550+
self.inner.transaction(keys::CORE).with_mode(TransactionMode::Readwrite).build()?;
15501551
transaction
15511552
.object_store(keys::CORE)?
15521553
.put(&self.serializer.serialize_value(&value)?)
@@ -1558,14 +1559,9 @@ impl_crypto_store! {
15581559

15591560
#[allow(clippy::unused_async)] // Mandated by trait on wasm.
15601561
async fn remove_custom_value(&self, key: &str) -> Result<()> {
1561-
let transaction = self.inner
1562-
.transaction(keys::CORE)
1563-
.with_mode(TransactionMode::Readwrite)
1564-
.build()?;
1565-
transaction
1566-
.object_store(keys::CORE)?
1567-
.delete(&JsValue::from_str(key))
1568-
.build()?;
1562+
let transaction =
1563+
self.inner.transaction(keys::CORE).with_mode(TransactionMode::Readwrite).build()?;
1564+
transaction.object_store(keys::CORE)?.delete(&JsValue::from_str(key)).build()?;
15691565
transaction.commit().await?;
15701566
Ok(())
15711567
}
@@ -1833,7 +1829,7 @@ where
18331829
}
18341830

18351831
/// The objects we store in the gossip_requests indexeddb object store
1836-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
1832+
#[derive(Debug, Serialize, Deserialize)]
18371833
struct GossipRequestIndexedDbObject {
18381834
/// Encrypted hash of the [`SecretInfo`] structure.
18391835
info: String,
@@ -1858,7 +1854,7 @@ struct GossipRequestIndexedDbObject {
18581854
}
18591855

18601856
/// The objects we store in the inbound_group_sessions3 indexeddb object store
1861-
#[derive(serde::Serialize, serde::Deserialize)]
1857+
#[derive(Serialize, Deserialize)]
18621858
struct InboundGroupSessionIndexedDbObject {
18631859
/// Possibly encrypted
18641860
/// [`matrix_sdk_crypto::olm::group_sessions::PickledInboundGroupSession`]

0 commit comments

Comments
 (0)