Skip to content

Commit 215f810

Browse files
committed
chore(ffi): Upgrade to Rust edition 2024
1 parent 29b693e commit 215f810

36 files changed

+130
-139
lines changed

bindings/matrix-sdk-crypto-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "matrix-sdk-crypto-ffi"
33
version = "0.1.0"
44
authors = ["Damir Jelić <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66
rust-version.workspace = true
77
description = "Uniffi based bindings for the Rust SDK crypto crate"
88
repository = "https://github.com/matrix-org/matrix-rust-sdk"

bindings/matrix-sdk-crypto-ffi/src/backup_recovery_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::{collections::HashMap, iter, ops::DerefMut, sync::Arc};
33
use hmac::Hmac;
44
use matrix_sdk_crypto::{
55
backups::DecryptionError,
6-
store::{types::BackupDecryptionKey, CryptoStoreError as InnerStoreError},
6+
store::{CryptoStoreError as InnerStoreError, types::BackupDecryptionKey},
77
};
88
use pbkdf2::pbkdf2;
9-
use rand::{distributions::Alphanumeric, thread_rng, Rng};
9+
use rand::{Rng, distributions::Alphanumeric, thread_rng};
1010
use sha2::Sha512;
1111
use thiserror::Error;
1212
use zeroize::Zeroize;

bindings/matrix-sdk-crypto-ffi/src/dehydrated_devices.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use std::{mem::ManuallyDrop, sync::Arc};
22

33
use matrix_sdk_common::executor::Handle;
44
use matrix_sdk_crypto::{
5+
DecryptionSettings,
56
dehydrated_devices::{
67
DehydratedDevice as InnerDehydratedDevice, DehydratedDevices as InnerDehydratedDevices,
78
RehydratedDevice as InnerRehydratedDevice,
89
},
910
store::types::DehydratedDeviceKey as InnerDehydratedDeviceKey,
10-
DecryptionSettings,
1111
};
12-
use ruma::{api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw, OwnedDeviceId};
12+
use ruma::{OwnedDeviceId, api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw};
1313
use serde_json::json;
1414

1515
use crate::{CryptoStoreError, DehydratedDeviceKey};
@@ -227,7 +227,7 @@ impl From<dehydrated_device::put_dehydrated_device::unstable::Request>
227227

228228
#[cfg(test)]
229229
mod tests {
230-
use crate::{dehydrated_devices::DehydrationError, DehydratedDeviceKey};
230+
use crate::{DehydratedDeviceKey, dehydrated_devices::DehydrationError};
231231

232232
#[test]
233233
fn test_creating_dehydrated_key() {

bindings/matrix-sdk-crypto-ffi/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(missing_docs)]
22

33
use matrix_sdk_crypto::{
4-
store::{CryptoStoreError as InnerStoreError, DehydrationError as InnerDehydrationError},
54
KeyExportError, MegolmError, OlmError, SecretImportError as RustSecretImportError,
65
SignatureError as InnerSignatureError,
6+
store::{CryptoStoreError as InnerStoreError, DehydrationError as InnerDehydrationError},
77
};
88
use matrix_sdk_sqlite::OpenStoreError;
99
use ruma::{IdParseError, OwnedUserId};

bindings/matrix-sdk-crypto-ffi/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,32 @@ pub use error::{
3131
CryptoStoreError, DecryptionError, KeyImportError, SecretImportError, SignatureError,
3232
};
3333
use js_int::UInt;
34-
pub use logger::{set_logger, Logger};
34+
pub use logger::{Logger, set_logger};
3535
pub use machine::{KeyRequestPair, OlmMachine, SignatureVerification};
3636
use matrix_sdk_common::deserialized_responses::{ShieldState as RustShieldState, ShieldStateCode};
3737
use matrix_sdk_crypto::{
38+
CollectStrategy, EncryptionSettings as RustEncryptionSettings,
3839
olm::{IdentityKeys, InboundGroupSession, SenderData, Session},
3940
store::{
41+
CryptoStore,
4042
types::{
4143
Changes, DehydratedDeviceKey as InnerDehydratedDeviceKey, PendingChanges,
4244
RoomSettings as RustRoomSettings,
4345
},
44-
CryptoStore,
4546
},
4647
types::{
4748
DeviceKey, DeviceKeys, EventEncryptionAlgorithm as RustEventEncryptionAlgorithm, SigningKey,
4849
},
49-
CollectStrategy, EncryptionSettings as RustEncryptionSettings,
5050
};
5151
use matrix_sdk_sqlite::SqliteCryptoStore;
5252
pub use responses::{
5353
BootstrapCrossSigningResult, DeviceLists, KeysImportResult, OutgoingVerificationRequest,
5454
Request, RequestType, SignatureUploadRequest, UploadSigningKeysRequest,
5555
};
5656
use ruma::{
57-
events::room::history_visibility::HistoryVisibility as RustHistoryVisibility,
5857
DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId,
5958
RoomId, SecondsSinceUnixEpoch, UserId,
59+
events::room::history_visibility::HistoryVisibility as RustHistoryVisibility,
6060
};
6161
use serde::{Deserialize, Serialize};
6262
use tokio::runtime::Runtime;
@@ -1048,11 +1048,11 @@ uniffi::setup_scaffolding!();
10481048
#[cfg(test)]
10491049
mod tests {
10501050
use anyhow::Result;
1051-
use serde_json::{json, Value};
1051+
use serde_json::{Value, json};
10521052
use tempfile::tempdir;
10531053

10541054
use super::MigrationData;
1055-
use crate::{migrate, EventEncryptionAlgorithm, OlmMachine, RoomSettings};
1055+
use crate::{EventEncryptionAlgorithm, OlmMachine, RoomSettings, migrate};
10561056

10571057
#[test]
10581058
fn android_migration() -> Result<()> {

bindings/matrix-sdk-crypto-ffi/src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
sync::{Arc, Mutex},
44
};
55

6-
use tracing_subscriber::{fmt::MakeWriter, EnvFilter};
6+
use tracing_subscriber::{EnvFilter, fmt::MakeWriter};
77

88
/// Trait that can be used to forward Rust logs over FFI to a language specific
99
/// logger.

bindings/matrix-sdk-crypto-ffi/src/machine.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use std::{
1010
use js_int::UInt;
1111
use matrix_sdk_common::deserialized_responses::AlgorithmInfo;
1212
use matrix_sdk_crypto::{
13+
CollectStrategy, DecryptionSettings, LocalTrust, OlmMachine as InnerMachine,
14+
UserIdentity as SdkUserIdentity,
1315
backups::{
1416
MegolmV1BackupKey as RustBackupKey, SignatureState,
1517
SignatureVerification as RustSignatureCheckResult,
@@ -18,11 +20,12 @@ use matrix_sdk_crypto::{
1820
olm::ExportedRoomKey,
1921
store::types::{BackupDecryptionKey, Changes},
2022
types::requests::ToDeviceRequest,
21-
CollectStrategy, DecryptionSettings, LocalTrust, OlmMachine as InnerMachine,
22-
UserIdentity as SdkUserIdentity,
2323
};
2424
use ruma::{
25+
DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId,
26+
UserId,
2527
api::{
28+
IncomingResponse,
2629
client::{
2730
backup::add_backup_keys::v3::Response as KeysBackupResponse,
2831
keys::{
@@ -32,35 +35,32 @@ use ruma::{
3235
upload_signatures::v3::Response as SignatureUploadResponse,
3336
},
3437
message::send_message_event::v3::Response as RoomMessageResponse,
35-
sync::sync_events::{v3::ToDevice, DeviceLists as RumaDeviceLists},
38+
sync::sync_events::{DeviceLists as RumaDeviceLists, v3::ToDevice},
3639
to_device::send_event_to_device::v3::Response as ToDeviceResponse,
3740
},
38-
IncomingResponse,
3941
},
4042
events::{
41-
key::verification::VerificationMethod, room::message::MessageType, AnyMessageLikeEvent,
42-
AnySyncMessageLikeEvent, AnyTimelineEvent, MessageLikeEvent,
43+
AnyMessageLikeEvent, AnySyncMessageLikeEvent, AnyTimelineEvent, MessageLikeEvent,
44+
key::verification::VerificationMethod, room::message::MessageType,
4345
},
4446
serde::Raw,
4547
to_device::DeviceIdOrAllDevices,
46-
DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId,
47-
UserId,
4848
};
4949
use serde::{Deserialize, Serialize};
50-
use serde_json::{value::RawValue, Value};
50+
use serde_json::{Value, value::RawValue};
5151
use tokio::runtime::Runtime;
5252
use zeroize::Zeroize;
5353

5454
use crate::{
55-
dehydrated_devices::DehydratedDevices,
56-
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
57-
parse_user_id,
58-
responses::{response_from_string, OwnedResponse},
5955
BackupKeys, BackupRecoveryKey, BootstrapCrossSigningResult, CrossSigningKeyExport,
6056
CrossSigningStatus, DecodeError, DecryptedEvent, Device, DeviceLists, EncryptionSettings,
6157
EventEncryptionAlgorithm, KeyImportError, KeysImportResult, MegolmV1BackupKey,
6258
ProgressListener, Request, RequestType, RequestVerificationResult, RoomKeyCounts, RoomSettings,
6359
Sas, SignatureUploadRequest, StartSasResult, UserIdentity, Verification, VerificationRequest,
60+
dehydrated_devices::DehydratedDevices,
61+
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
62+
parse_user_id,
63+
responses::{OwnedResponse, response_from_string},
6464
};
6565

6666
/// The return value for the [`OlmMachine::receive_sync_changes()`] method.

bindings/matrix-sdk-crypto-ffi/src/responses.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ use std::collections::HashMap;
44

55
use http::Response;
66
use matrix_sdk_crypto::{
7+
CrossSigningBootstrapRequests,
78
types::requests::{
89
AnyIncomingResponse, KeysBackupRequest, OutgoingRequest,
910
OutgoingVerificationRequest as SdkVerificationRequest, RoomMessageRequest, ToDeviceRequest,
1011
UploadSigningKeysRequest as RustUploadSigningKeysRequest,
1112
},
12-
CrossSigningBootstrapRequests,
1313
};
1414
use ruma::{
15+
OwnedTransactionId, UserId,
1516
api::client::{
1617
backup::add_backup_keys::v3::Response as KeysBackupResponse,
1718
keys::{
@@ -28,7 +29,6 @@ use ruma::{
2829
},
2930
assign,
3031
events::MessageLikeEventContent,
31-
OwnedTransactionId, UserId,
3232
};
3333
use serde_json::json;
3434

bindings/matrix-sdk-crypto-ffi/src/users.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use matrix_sdk_crypto::{types::CrossSigningKey, UserIdentity as SdkUserIdentity};
1+
use matrix_sdk_crypto::{UserIdentity as SdkUserIdentity, types::CrossSigningKey};
22

33
use crate::CryptoStoreError;
44

bindings/matrix-sdk-crypto-ffi/src/verification.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ use std::sync::Arc;
33
use futures_util::{Stream, StreamExt};
44
use matrix_sdk_common::executor::Handle;
55
use matrix_sdk_crypto::{
6-
matrix_sdk_qrcode::QrVerificationData, CancelInfo as RustCancelInfo, QrVerification as InnerQr,
7-
QrVerificationState, Sas as InnerSas, SasState as RustSasState,
8-
Verification as InnerVerification, VerificationRequest as InnerVerificationRequest,
6+
CancelInfo as RustCancelInfo, QrVerification as InnerQr, QrVerificationState, Sas as InnerSas,
7+
SasState as RustSasState, Verification as InnerVerification,
8+
VerificationRequest as InnerVerificationRequest,
99
VerificationRequestState as RustVerificationRequestState,
10+
matrix_sdk_qrcode::QrVerificationData,
1011
};
1112
use ruma::events::key::verification::VerificationMethod;
1213
use vodozemac::{base64_decode, base64_encode};

0 commit comments

Comments
 (0)