Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ format_code_in_doc_comments = true
doc_comment_code_block_width = 80
# Workaround for https://github.com/rust-lang/rust.vim/issues/464
edition = "2021"
style_edition = "2024"
5 changes: 3 additions & 2 deletions benchmarks/benches/crypto_bench.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use std::{ops::Deref, sync::Arc};

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{BatchSize, 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,
api::client::{
keys::{claim_keys, get_keys},
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
},
device_id, room_id, user_id, DeviceId, OwnedUserId, TransactionId, UserId,
device_id, room_id, user_id,
};
use serde_json::Value;
use tokio::runtime::Builder;
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/benches/linked_chunk.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::{sync::Arc, time::Duration};

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use matrix_sdk::{
linked_chunk::{lazy_loader, LinkedChunk, LinkedChunkId, Update},
SqliteEventCacheStore,
linked_chunk::{LinkedChunk, LinkedChunkId, Update, lazy_loader},
};
use matrix_sdk_base::event_cache::{
store::{DynEventCacheStore, IntoEventCacheStore, MemoryStore, DEFAULT_CHUNK_CAPACITY},
Event, Gap,
store::{DEFAULT_CHUNK_CAPACITY, DynEventCacheStore, IntoEventCacheStore, MemoryStore},
};
use matrix_sdk_test::{event_factory::EventFactory, ALICE};
use ruma::{room_id, EventId};
use matrix_sdk_test::{ALICE, event_factory::EventFactory};
use ruma::{EventId, room_id};
use tempfile::tempdir;
use tokio::runtime::Builder;

Expand Down
9 changes: 5 additions & 4 deletions benchmarks/benches/room_bench.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use std::time::Duration;

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use matrix_sdk::{store::RoomLoadSettings, test_utils::mocks::MatrixMockServer};
use matrix_sdk_base::{
store::StoreConfig, BaseClient, RoomInfo, RoomState, SessionMeta, StateChanges, StateStore,
BaseClient, RoomInfo, RoomState, SessionMeta, StateChanges, StateStore, store::StoreConfig,
};
use matrix_sdk_sqlite::SqliteStateStore;
use matrix_sdk_test::{event_factory::EventFactory, JoinedRoomBuilder, StateTestEvent};
use matrix_sdk_test::{JoinedRoomBuilder, StateTestEvent, event_factory::EventFactory};
use matrix_sdk_ui::timeline::{TimelineBuilder, TimelineFocus};
use ruma::{
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
api::client::membership::get_member_events,
device_id,
events::room::member::{MembershipState, RoomMemberEvent},
mxc_uri, owned_room_id, owned_user_id,
serde::Raw,
user_id, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
user_id,
};
use serde_json::json;
use tokio::runtime::Builder;
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/benches/store_bench.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::sync::Arc;

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use matrix_sdk::{
authentication::matrix::MatrixSession, config::StoreConfig, Client, RoomInfo, RoomState,
SessionTokens, StateChanges,
Client, RoomInfo, RoomState, SessionTokens, StateChanges,
authentication::matrix::MatrixSession, config::StoreConfig,
};
use matrix_sdk_base::{store::MemoryStore, SessionMeta, StateStore as _};
use matrix_sdk_base::{SessionMeta, StateStore as _, store::MemoryStore};
use matrix_sdk_sqlite::SqliteStateStore;
use ruma::{device_id, user_id, RoomId};
use ruma::{RoomId, device_id, user_id};
use tokio::runtime::Builder;

fn criterion() -> Criterion {
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/benches/timeline.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use matrix_sdk::test_utils::mocks::MatrixMockServer;
use matrix_sdk_test::{event_factory::EventFactory, JoinedRoomBuilder, StateTestEvent};
use matrix_sdk_test::{JoinedRoomBuilder, StateTestEvent, event_factory::EventFactory};
use matrix_sdk_ui::timeline::TimelineBuilder;
use ruma::{
events::room::message::RoomMessageEventContentWithoutRelation, owned_room_id, owned_user_id,
EventId,
EventId, events::room::message::RoomMessageEventContentWithoutRelation, owned_room_id,
owned_user_id,
};
use tokio::runtime::Builder;

Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-crypto-ffi/src/backup_recovery_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::{collections::HashMap, iter, ops::DerefMut, sync::Arc};
use hmac::Hmac;
use matrix_sdk_crypto::{
backups::DecryptionError,
store::{types::BackupDecryptionKey, CryptoStoreError as InnerStoreError},
store::{CryptoStoreError as InnerStoreError, types::BackupDecryptionKey},
};
use pbkdf2::pbkdf2;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::{Rng, distributions::Alphanumeric, thread_rng};
use sha2::Sha512;
use thiserror::Error;
use zeroize::Zeroize;
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 @@ -8,7 +8,7 @@ use matrix_sdk_crypto::{
},
store::types::DehydratedDeviceKey as InnerDehydratedDeviceKey,
};
use ruma::{api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw, OwnedDeviceId};
use ruma::{OwnedDeviceId, api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw};
use serde_json::json;

use crate::{CryptoStoreError, DehydratedDeviceKey};
Expand Down Expand Up @@ -222,7 +222,7 @@ impl From<dehydrated_device::put_dehydrated_device::unstable::Request>

#[cfg(test)]
mod tests {
use crate::{dehydrated_devices::DehydrationError, DehydratedDeviceKey};
use crate::{DehydratedDeviceKey, dehydrated_devices::DehydrationError};

#[test]
fn test_creating_dehydrated_key() {
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-crypto-ffi/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(missing_docs)]

use matrix_sdk_crypto::{
store::{CryptoStoreError as InnerStoreError, DehydrationError as InnerDehydrationError},
KeyExportError, MegolmError, OlmError, SecretImportError as RustSecretImportError,
SignatureError as InnerSignatureError,
store::{CryptoStoreError as InnerStoreError, DehydrationError as InnerDehydrationError},
};
use matrix_sdk_sqlite::OpenStoreError;
use ruma::{IdParseError, OwnedUserId};
Expand Down
12 changes: 6 additions & 6 deletions bindings/matrix-sdk-crypto-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ pub use error::{
CryptoStoreError, DecryptionError, KeyImportError, SecretImportError, SignatureError,
};
use js_int::UInt;
pub use logger::{set_logger, Logger};
pub use logger::{Logger, set_logger};
pub use machine::{KeyRequestPair, OlmMachine, SignatureVerification};
use matrix_sdk_common::deserialized_responses::{ShieldState as RustShieldState, ShieldStateCode};
use matrix_sdk_crypto::{
CollectStrategy, EncryptionSettings as RustEncryptionSettings,
olm::{IdentityKeys, InboundGroupSession, SenderData, Session},
store::{
CryptoStore,
types::{
Changes, DehydratedDeviceKey as InnerDehydratedDeviceKey, PendingChanges,
RoomSettings as RustRoomSettings,
},
CryptoStore,
},
types::{
DeviceKey, DeviceKeys, EventEncryptionAlgorithm as RustEventEncryptionAlgorithm, SigningKey,
},
CollectStrategy, EncryptionSettings as RustEncryptionSettings,
};
use matrix_sdk_sqlite::SqliteCryptoStore;
pub use responses::{
BootstrapCrossSigningResult, DeviceLists, KeysImportResult, OutgoingVerificationRequest,
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,
};
use serde::{Deserialize, Serialize};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -1034,11 +1034,11 @@ uniffi::setup_scaffolding!();
#[cfg(test)]
mod tests {
use anyhow::Result;
use serde_json::{json, Value};
use serde_json::{Value, json};
use tempfile::tempdir;

use super::MigrationData;
use crate::{migrate, EventEncryptionAlgorithm, OlmMachine, RoomSettings};
use crate::{EventEncryptionAlgorithm, OlmMachine, RoomSettings, migrate};

#[test]
fn android_migration() -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-crypto-ffi/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
sync::{Arc, Mutex},
};

use tracing_subscriber::{fmt::MakeWriter, EnvFilter};
use tracing_subscriber::{EnvFilter, fmt::MakeWriter};

/// Trait that can be used to forward Rust logs over FFI to a language specific
/// logger.
Expand Down
24 changes: 12 additions & 12 deletions bindings/matrix-sdk-crypto-ffi/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
use js_int::UInt;
use matrix_sdk_common::deserialized_responses::AlgorithmInfo;
use matrix_sdk_crypto::{
DecryptionSettings, LocalTrust, OlmMachine as InnerMachine, UserIdentity as SdkUserIdentity,
backups::{
MegolmV1BackupKey as RustBackupKey, SignatureState,
SignatureVerification as RustSignatureCheckResult,
Expand All @@ -18,10 +19,12 @@ use matrix_sdk_crypto::{
olm::ExportedRoomKey,
store::types::{BackupDecryptionKey, Changes},
types::requests::ToDeviceRequest,
DecryptionSettings, LocalTrust, OlmMachine as InnerMachine, UserIdentity as SdkUserIdentity,
};
use ruma::{
DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId,
UserId,
api::{
IncomingResponse,
client::{
backup::add_backup_keys::v3::Response as KeysBackupResponse,
keys::{
Expand All @@ -31,35 +34,32 @@ use ruma::{
upload_signatures::v3::Response as SignatureUploadResponse,
},
message::send_message_event::v3::Response as RoomMessageResponse,
sync::sync_events::{v3::ToDevice, DeviceLists as RumaDeviceLists},
sync::sync_events::{DeviceLists as RumaDeviceLists, v3::ToDevice},
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
},
IncomingResponse,
},
events::{
key::verification::VerificationMethod, room::message::MessageType, AnyMessageLikeEvent,
AnySyncMessageLikeEvent, MessageLikeEvent,
AnyMessageLikeEvent, AnySyncMessageLikeEvent, MessageLikeEvent,
key::verification::VerificationMethod, room::message::MessageType,
},
serde::Raw,
to_device::DeviceIdOrAllDevices,
DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId,
UserId,
};
use serde::{Deserialize, Serialize};
use serde_json::{value::RawValue, Value};
use serde_json::{Value, value::RawValue};
use tokio::runtime::Runtime;
use zeroize::Zeroize;

use crate::{
dehydrated_devices::DehydratedDevices,
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
parse_user_id,
responses::{response_from_string, OwnedResponse},
BackupKeys, BackupRecoveryKey, BootstrapCrossSigningResult, CrossSigningKeyExport,
CrossSigningStatus, DecodeError, DecryptedEvent, Device, DeviceLists, EncryptionSettings,
EventEncryptionAlgorithm, KeyImportError, KeysImportResult, MegolmV1BackupKey,
ProgressListener, Request, RequestType, RequestVerificationResult, RoomKeyCounts, RoomSettings,
Sas, SignatureUploadRequest, StartSasResult, UserIdentity, Verification, VerificationRequest,
dehydrated_devices::DehydratedDevices,
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
parse_user_id,
responses::{OwnedResponse, response_from_string},
};

/// The return value for the [`OlmMachine::receive_sync_changes()`] method.
Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-crypto-ffi/src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ use std::collections::HashMap;

use http::Response;
use matrix_sdk_crypto::{
CrossSigningBootstrapRequests,
types::requests::{
AnyIncomingResponse, KeysBackupRequest, OutgoingRequest,
OutgoingVerificationRequest as SdkVerificationRequest, RoomMessageRequest, ToDeviceRequest,
UploadSigningKeysRequest as RustUploadSigningKeysRequest,
},
CrossSigningBootstrapRequests,
};
use ruma::{
OwnedTransactionId, UserId,
api::client::{
backup::add_backup_keys::v3::Response as KeysBackupResponse,
keys::{
Expand All @@ -28,7 +29,6 @@ use ruma::{
},
assign,
events::EventContent,
OwnedTransactionId, UserId,
};
use serde_json::json;

Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-crypto-ffi/src/users.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use matrix_sdk_crypto::{types::CrossSigningKey, UserIdentity as SdkUserIdentity};
use matrix_sdk_crypto::{UserIdentity as SdkUserIdentity, types::CrossSigningKey};

use crate::CryptoStoreError;

Expand Down
7 changes: 4 additions & 3 deletions bindings/matrix-sdk-crypto-ffi/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use std::sync::Arc;
use futures_util::{Stream, StreamExt};
use matrix_sdk_common::executor::Handle;
use matrix_sdk_crypto::{
matrix_sdk_qrcode::QrVerificationData, CancelInfo as RustCancelInfo, QrVerification as InnerQr,
QrVerificationState, Sas as InnerSas, SasState as RustSasState,
Verification as InnerVerification, VerificationRequest as InnerVerificationRequest,
CancelInfo as RustCancelInfo, QrVerification as InnerQr, QrVerificationState, Sas as InnerSas,
SasState as RustSasState, Verification as InnerVerification,
VerificationRequest as InnerVerificationRequest,
VerificationRequestState as RustVerificationRequestState,
matrix_sdk_qrcode::QrVerificationData,
};
use ruma::events::key::verification::VerificationMethod;
use vodozemac::{base64_decode, base64_encode};
Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-ffi/src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::{
};

use matrix_sdk::{
Error,
authentication::oauth::{
ClientId, ClientRegistrationData, OAuthError as SdkOAuthError,
error::OAuthAuthorizationCodeError,
registration::{ApplicationType, ClientMetadata, Localized, OAuthGrantType},
ClientId, ClientRegistrationData, OAuthError as SdkOAuthError,
},
Error,
};
use ruma::serde::Raw;
use url::Url;
Expand Down
Loading
Loading