Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rand = { version = "0.8.5", default-features = false, features = ["std", "std_rn
regex = { version = "1.12.2", default-features = false }
reqwest = { version = "0.12.24", default-features = false }
rmp-serde = { version = "1.3.0", default-features = false }
ruma = { git = "https://github.com/ruma/ruma", rev = "289bee87974bd3c2ad14a6c15801c80b683b67dc", features = [
ruma = { git = "https://github.com/ruma/ruma", rev = "4ec4532a0e5b328283c729aefafa8a1cbef2204a", features = [
"client-api-c",
"compat-unset-avatar",
"compat-upload-signatures",
Expand Down
27 changes: 9 additions & 18 deletions benchmarks/benches/crypto_bench.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{ops::Deref, sync::Arc};
use std::sync::Arc;

use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use matrix_sdk_crypto::{EncryptionSettings, OlmMachine};
use matrix_sdk_sqlite::SqliteCryptoStore;
use matrix_sdk_test::ruma_response_from_json;
use ruma::{
DeviceId, OwnedUserId, TransactionId, UserId,
DeviceId, TransactionId, UserId,
api::client::{
keys::{claim_keys, get_keys},
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
let room_id = room_id!("!test:localhost");

let to_device_response = ToDeviceResponse::new();
let users: Vec<OwnedUserId> = keys_query_response.device_keys.keys().cloned().collect();
let users: Vec<UserId> = keys_query_response.device_keys.keys().cloned().collect();

let count = response.one_time_keys.values().fold(0, |acc, d| acc + d.len());

Expand All @@ -199,11 +199,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
group.bench_function(BenchmarkId::new("Room key sharing [memory]", &name), |b| {
b.to_async(&runtime).iter(|| async {
let requests = machine
.share_room_key(
room_id,
users.iter().map(Deref::deref),
EncryptionSettings::default(),
)
.share_room_key(room_id, users.iter(), EncryptionSettings::default())
.await
.unwrap();

Expand Down Expand Up @@ -231,11 +227,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
group.bench_function(BenchmarkId::new("Room key sharing [SQLite]", &name), |b| {
b.to_async(&runtime).iter(|| async {
let requests = machine
.share_room_key(
room_id,
users.iter().map(Deref::deref),
EncryptionSettings::default(),
)
.share_room_key(room_id, users.iter(), EncryptionSettings::default())
.await
.unwrap();

Expand Down Expand Up @@ -263,7 +255,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
let machine = runtime.block_on(OlmMachine::new(alice_id(), alice_device_id()));
let response = huge_keys_query_response();
let txn_id = TransactionId::new();
let users: Vec<OwnedUserId> = response.device_keys.keys().cloned().collect();
let users: Vec<UserId> = response.device_keys.keys().cloned().collect();

let count = response.device_keys.values().fold(0, |acc, d| acc + d.len());

Expand All @@ -278,7 +270,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {

group.bench_function(BenchmarkId::new("Devices collecting [memory]", &name), |b| {
b.to_async(&runtime).iter_with_large_drop(|| async {
machine.get_missing_sessions(users.iter().map(Deref::deref)).await.unwrap()
machine.get_missing_sessions(users.iter()).await.unwrap()
})
});

Expand All @@ -294,9 +286,8 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();

group.bench_function(BenchmarkId::new("Devices collecting [SQLite]", &name), |b| {
b.to_async(&runtime).iter(|| async {
machine.get_missing_sessions(users.iter().map(Deref::deref)).await.unwrap()
})
b.to_async(&runtime)
.iter(|| async { machine.get_missing_sessions(users.iter()).await.unwrap() })
});

{
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/event_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ fn find_event_relations(c: &mut Criterion) {
.await
.unwrap()
.unwrap();
assert_eq!(target.event_id().as_deref().unwrap(), target_event_id);
assert_eq!(target.event_id().unwrap(), target_event_id);
assert_eq!(relations.len(), num_related_events as usize);
},
criterion::BatchSize::PerIteration,
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benches/room_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use matrix_sdk_sqlite::SqliteStateStore;
use matrix_sdk_test::{JoinedRoomBuilder, event_factory::EventFactory};
use matrix_sdk_ui::timeline::{TimelineBuilder, TimelineFocus};
use ruma::{
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
EventId, MilliSecondsSinceUnixEpoch, UserId,
api::client::membership::get_member_events,
events::room::member::{MembershipState, RoomMemberEvent},
mxc_uri, owned_device_id, owned_room_id, owned_user_id,
Expand All @@ -31,7 +31,7 @@ pub fn receive_all_members_benchmark(c: &mut Criterion) {
let f = EventFactory::new().room(&room_id);
let mut member_events: Vec<Raw<RoomMemberEvent>> = Vec::with_capacity(MEMBERS_IN_ROOM);
for i in 0..MEMBERS_IN_ROOM {
let user_id = OwnedUserId::try_from(format!("@user_{i}:matrix.org")).unwrap();
let user_id = UserId::try_from(format!("@user_{i}:matrix.org")).unwrap();
let event = f
.member(&user_id)
.membership(MembershipState::Join)
Expand Down Expand Up @@ -113,7 +113,7 @@ pub fn load_pinned_events_benchmark(c: &mut Criterion) {
let mut joined_room_builder =
JoinedRoomBuilder::new(&room_id).add_state_event(f.room_encryption());

let pinned_event_ids: Vec<OwnedEventId> = (0..PINNED_EVENTS_COUNT)
let pinned_event_ids: Vec<EventId> = (0..PINNED_EVENTS_COUNT)
.map(|i| EventId::parse(format!("${i}")).expect("Invalid event id"))
.collect();
joined_room_builder =
Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-crypto-ffi/src/dehydrated_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use matrix_sdk_crypto::{
store::types::DehydratedDeviceKey as InnerDehydratedDeviceKey,
DecryptionSettings,
};
use ruma::{api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw, OwnedDeviceId};
use ruma::{api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw, DeviceId};
use serde_json::json;

use crate::{CryptoStoreError, DehydratedDeviceKey};
Expand Down Expand Up @@ -86,7 +86,7 @@ impl DehydratedDevices {
device_data: String,
) -> Result<Arc<RehydratedDevice>, DehydrationError> {
let device_data: Raw<_> = serde_json::from_str(&device_data)?;
let device_id: OwnedDeviceId = device_id.into();
let device_id: DeviceId = device_id.into();

let key = InnerDehydratedDeviceKey::from_slice(&pickle_key.inner)?;

Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-crypto-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use matrix_sdk_crypto::{
SignatureError as InnerSignatureError,
};
use matrix_sdk_sqlite::OpenStoreError;
use ruma::{IdParseError, OwnedUserId};
use ruma::{IdParseError, UserId};

#[derive(Debug, thiserror::Error, uniffi::Error)]
#[uniffi(flat_error)]
Expand Down Expand Up @@ -38,7 +38,7 @@ pub enum SignatureError {
#[error(transparent)]
CryptoStore(#[from] InnerStoreError),
#[error("Unknown device {0} {1}")]
UnknownDevice(OwnedUserId, String),
UnknownDevice(UserId, String),
#[error("Unknown user identity {0}")]
UnknownUserIdentity(String),
}
Expand Down
20 changes: 10 additions & 10 deletions bindings/matrix-sdk-crypto-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ pub use responses::{
Request, RequestType, SignatureUploadRequest, UploadSigningKeysRequest,
};
use ruma::{
events::room::history_visibility::HistoryVisibility as RustHistoryVisibility,
DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId,
RoomId, SecondsSinceUnixEpoch, UserId,
events::room::history_visibility::HistoryVisibility as RustHistoryVisibility, DeviceId,
DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, RoomId, SecondsSinceUnixEpoch,
UserId,
};
use serde::{Deserialize, Serialize};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -248,7 +248,7 @@ async fn migrate_data(
listener(processed_steps, total_steps);

let user_id = parse_user_id(&data.account.user_id)?;
let device_id: OwnedDeviceId = data.account.device_id.into();
let device_id: DeviceId = data.account.device_id.into();

let account = Account::from_libolm_pickle(&data.account.pickle, &data.pickle_key)?;
let pickle = account.pickle();
Expand Down Expand Up @@ -285,7 +285,7 @@ async fn migrate_data(
.map(|k| BackupDecryptionKey::from_base58(k.as_str()))
.transpose()?;

let cross_signing = PrivateCrossSigningIdentity::empty((*user_id).into());
let cross_signing = PrivateCrossSigningIdentity::empty(&user_id);
cross_signing
.import_secrets_unchecked(
data.cross_signing.master_key.as_deref(),
Expand All @@ -307,7 +307,7 @@ async fn migrate_data(
.filter_map(|s| parse_user_id(&s).ok().map(|u| (u, true)))
.collect();

let tracked_users: Vec<_> = tracked_users.iter().map(|(u, d)| (&**u, *d)).collect();
let tracked_users: Vec<_> = tracked_users.iter().map(|(u, d)| (u, *d)).collect();
store.save_tracked_users(tracked_users.as_slice()).await?;

processed_steps += 1;
Expand Down Expand Up @@ -395,7 +395,7 @@ async fn migrate_session_data(
let processed_steps = 0;

let user_id = UserId::parse(data.user_id)?;
let device_id: OwnedDeviceId = data.device_id.into();
let device_id: DeviceId = data.device_id.into();

let identity_keys = IdentityKeys {
ed25519: Ed25519PublicKey::from_base64(&data.ed25519_key)?,
Expand Down Expand Up @@ -425,8 +425,8 @@ fn collect_sessions(
total_steps: usize,
listener: &dyn Fn(usize, usize),
pickle_key: &[u8],
user_id: OwnedUserId,
device_id: OwnedDeviceId,
user_id: UserId,
device_id: DeviceId,
identity_keys: Arc<IdentityKeys>,
session_pickles: Vec<PickledSession>,
group_session_pickles: Vec<PickledInboundGroupSession>,
Expand Down Expand Up @@ -949,7 +949,7 @@ impl From<RoomSettings> for RustRoomSettings {
}
}

fn parse_user_id(user_id: &str) -> Result<OwnedUserId, CryptoStoreError> {
fn parse_user_id(user_id: &str) -> Result<UserId, CryptoStoreError> {
ruma::UserId::parse(user_id).map_err(|e| CryptoStoreError::InvalidUserId(user_id.to_owned(), e))
}

Expand Down
Loading
Loading