Skip to content

Commit 2e32a8b

Browse files
committed
Format with imports_granularity = "Module"
This is the result of running `cargo +nightly fmt` with the unstable `rustfmt` option `imports_granularity = "Module"`. Personally, I find this style much easier to use: - The lack of deep nesting makes it easier for me to understand the imports at a glance. - Because most imports are on a single line, I can add/remove them easier. Copy-pasting between files is easier. Of course, this option is unstable, meaning that it has no effect on a stable `rustfmt`. Luckily, the default value for `imports_granularity` is `Preserve`, which means that the formatting done here will be preserved by future `cargo fmt` calls: https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#imports_granularity This applies to both on the stable and nightly channels.
1 parent 6f905df commit 2e32a8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+994
-1220
lines changed

mls-rs/benches/group_add.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

55
use criterion::{BatchSize, BenchmarkId, Criterion};
6-
use mls_rs::{
7-
client_builder::MlsConfig,
8-
identity::{
9-
basic::{BasicCredential, BasicIdentityProvider},
10-
SigningIdentity,
11-
},
12-
mls_rules::{CommitOptions, DefaultMlsRules},
13-
CipherSuite, CipherSuiteProvider, Client, CryptoProvider,
14-
};
6+
use mls_rs::client_builder::MlsConfig;
7+
use mls_rs::identity::basic::{BasicCredential, BasicIdentityProvider};
8+
use mls_rs::identity::SigningIdentity;
9+
use mls_rs::mls_rules::{CommitOptions, DefaultMlsRules};
10+
use mls_rs::{CipherSuite, CipherSuiteProvider, Client, CryptoProvider};
1511
use mls_rs_crypto_openssl::OpensslCryptoProvider;
1612

1713
fn bench(c: &mut Criterion) {

mls-rs/benches/group_commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

55
use criterion::{BatchSize, BenchmarkId, Criterion};
6-
use mls_rs::{test_utils::benchmarks::load_group_states, CipherSuite};
6+
use mls_rs::test_utils::benchmarks::load_group_states;
7+
use mls_rs::CipherSuite;
78

89
fn bench(c: &mut Criterion) {
910
let cipher_suite = CipherSuite::CURVE25519_AES128;

mls-rs/benches/group_receive_commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

55
use criterion::{BatchSize, BenchmarkId, Criterion};
6-
use mls_rs::{test_utils::benchmarks::load_group_states, CipherSuite};
6+
use mls_rs::test_utils::benchmarks::load_group_states;
7+
use mls_rs::CipherSuite;
78

89
fn bench(c: &mut Criterion) {
910
let cipher_suite = CipherSuite::CURVE25519_AES128;

mls-rs/benches/group_serialize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Copyright by contributors to this project.
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5-
use mls_rs::{test_utils::benchmarks::load_group_states, CipherSuite};
5+
use mls_rs::test_utils::benchmarks::load_group_states;
6+
use mls_rs::CipherSuite;
67

78
use criterion::{BenchmarkId, Criterion};
89

mls-rs/examples/basic_server_usage.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
// Copyright by contributors to this project.
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5-
use mls_rs::{
6-
client_builder::MlsConfig,
7-
error::MlsError,
8-
external_client::{
9-
builder::MlsConfig as ExternalMlsConfig, ExternalClient, ExternalReceivedMessage,
10-
ExternalSnapshot,
11-
},
12-
group::{CachedProposal, ReceivedMessage},
13-
identity::{
14-
basic::{BasicCredential, BasicIdentityProvider},
15-
SigningIdentity,
16-
},
17-
CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList, MlsMessage,
18-
};
5+
use mls_rs::client_builder::MlsConfig;
6+
use mls_rs::error::MlsError;
7+
use mls_rs::external_client::builder::MlsConfig as ExternalMlsConfig;
8+
use mls_rs::external_client::{ExternalClient, ExternalReceivedMessage, ExternalSnapshot};
9+
use mls_rs::group::{CachedProposal, ReceivedMessage};
10+
use mls_rs::identity::basic::{BasicCredential, BasicIdentityProvider};
11+
use mls_rs::identity::SigningIdentity;
12+
use mls_rs::{CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList, MlsMessage};
1913
use mls_rs_core::crypto::SignatureSecretKey;
2014

2115
const CIPHERSUITE: CipherSuite = CipherSuite::CURVE25519_AES128;

mls-rs/examples/basic_usage.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
// Copyright by contributors to this project.
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5-
use mls_rs::{
6-
client_builder::MlsConfig,
7-
error::MlsError,
8-
identity::{
9-
basic::{BasicCredential, BasicIdentityProvider},
10-
SigningIdentity,
11-
},
12-
CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList,
13-
};
5+
use mls_rs::client_builder::MlsConfig;
6+
use mls_rs::error::MlsError;
7+
use mls_rs::identity::basic::{BasicCredential, BasicIdentityProvider};
8+
use mls_rs::identity::SigningIdentity;
9+
use mls_rs::{CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList};
1410

1511
const CIPHERSUITE: CipherSuite = CipherSuite::CURVE25519_AES128;
1612

mls-rs/examples/custom.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,26 @@
2424
/// * Proposal validation rules that enforce 1. above.
2525
///
2626
use assert_matches::assert_matches;
27+
use mls_rs::client_builder::{MlsConfig, PaddingMode};
28+
use mls_rs::error::MlsError;
29+
use mls_rs::group::proposal::{MlsCustomProposal, Proposal};
30+
use mls_rs::group::{Roster, Sender};
31+
use mls_rs::mls_rules::{
32+
CommitDirection, CommitOptions, CommitSource, EncryptionOptions, ProposalBundle, ProposalSource,
33+
};
2734
use mls_rs::{
28-
client_builder::{MlsConfig, PaddingMode},
29-
error::MlsError,
30-
group::{
31-
proposal::{MlsCustomProposal, Proposal},
32-
Roster, Sender,
33-
},
34-
mls_rules::{
35-
CommitDirection, CommitOptions, CommitSource, EncryptionOptions, ProposalBundle,
36-
ProposalSource,
37-
},
3835
CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList, IdentityProvider,
3936
MlsRules,
4037
};
4138
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
42-
use mls_rs_core::{
43-
crypto::{SignaturePublicKey, SignatureSecretKey},
44-
error::IntoAnyError,
45-
extension::{ExtensionError, ExtensionType, MlsCodecExtension},
46-
group::ProposalType,
47-
identity::{Credential, CredentialType, CustomCredential, MlsCredential, SigningIdentity},
48-
time::MlsTime,
39+
use mls_rs_core::crypto::{SignaturePublicKey, SignatureSecretKey};
40+
use mls_rs_core::error::IntoAnyError;
41+
use mls_rs_core::extension::{ExtensionError, ExtensionType, MlsCodecExtension};
42+
use mls_rs_core::group::ProposalType;
43+
use mls_rs_core::identity::{
44+
Credential, CredentialType, CustomCredential, MlsCredential, SigningIdentity,
4945
};
46+
use mls_rs_core::time::MlsTime;
5047

5148
use std::fmt::Display;
5249

mls-rs/examples/large_group.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
// Copyright by contributors to this project.
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5-
use mls_rs::{
6-
client_builder::MlsConfig,
7-
error::MlsError,
8-
identity::{
9-
basic::{BasicCredential, BasicIdentityProvider},
10-
SigningIdentity,
11-
},
12-
mls_rules::{CommitOptions, DefaultMlsRules},
13-
CipherSuite, CipherSuiteProvider, Client, CryptoProvider, Group,
14-
};
5+
use mls_rs::client_builder::MlsConfig;
6+
use mls_rs::error::MlsError;
7+
use mls_rs::identity::basic::{BasicCredential, BasicIdentityProvider};
8+
use mls_rs::identity::SigningIdentity;
9+
use mls_rs::mls_rules::{CommitOptions, DefaultMlsRules};
10+
use mls_rs::{CipherSuite, CipherSuiteProvider, Client, CryptoProvider, Group};
1511

1612
const CIPHERSUITE: CipherSuite = CipherSuite::CURVE25519_AES128;
1713
const GROUP_SIZES: [usize; 8] = [2, 3, 5, 9, 17, 33, 65, 129];

mls-rs/src/client.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ use crate::client_builder::{recreate_config, BaseConfig, ClientBuilder, MakeConf
77
use crate::client_config::ClientConfig;
88
use crate::group::framing::MlsMessage;
99

10+
use crate::group::snapshot::Snapshot;
1011
#[cfg(feature = "by_ref_proposal")]
1112
use crate::group::{
1213
framing::{Content, MlsMessagePayload, PublicMessage, Sender, WireFormat},
1314
message_signature::AuthenticatedContent,
1415
proposal::{AddProposal, Proposal},
1516
};
16-
use crate::group::{snapshot::Snapshot, ExportedTree, Group, NewMemberInfo};
17+
use crate::group::{ExportedTree, Group, NewMemberInfo};
1718
use crate::identity::SigningIdentity;
1819
use crate::key_package::{KeyPackageGeneration, KeyPackageGenerator};
1920
use crate::protocol_version::ProtocolVersion;
@@ -784,22 +785,16 @@ mod tests {
784785
use super::test_utils::*;
785786

786787
use super::*;
787-
use crate::{
788-
crypto::test_utils::TestCryptoProvider,
789-
identity::test_utils::{get_test_basic_credential, get_test_signing_identity},
790-
tree_kem::leaf_node::LeafNodeSource,
791-
};
788+
use crate::crypto::test_utils::TestCryptoProvider;
789+
use crate::identity::test_utils::{get_test_basic_credential, get_test_signing_identity};
790+
use crate::tree_kem::leaf_node::LeafNodeSource;
792791
use assert_matches::assert_matches;
793792

794-
use crate::{
795-
group::{
796-
message_processor::ProposalMessageDescription,
797-
proposal::Proposal,
798-
test_utils::{test_group, test_group_custom_config},
799-
ReceivedMessage,
800-
},
801-
psk::{ExternalPskId, PreSharedKey},
802-
};
793+
use crate::group::message_processor::ProposalMessageDescription;
794+
use crate::group::proposal::Proposal;
795+
use crate::group::test_utils::{test_group, test_group_custom_config};
796+
use crate::group::ReceivedMessage;
797+
use crate::psk::{ExternalPskId, PreSharedKey};
803798

804799
use alloc::vec;
805800

@@ -893,7 +888,8 @@ mod tests {
893888
// interim_transcript_hash to be computed from the confirmed_transcript_hash and
894889
// confirmation_tag, which is not the case for the initial interim_transcript_hash.
895890

896-
use crate::group::{message_processor::CommitEffect, CommitMessageDescription};
891+
use crate::group::message_processor::CommitEffect;
892+
use crate::group::CommitMessageDescription;
897893

898894
let psk = PreSharedKey::from(b"psk".to_vec());
899895
let psk_id = ExternalPskId::new(b"psk id".to_vec());

mls-rs/src/client_builder.rs

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,20 @@
66
//!
77
//! See [`ClientBuilder`].
88
9-
use crate::{
10-
cipher_suite::CipherSuite,
11-
client::Client,
12-
client_config::ClientConfig,
13-
extension::{ExtensionType, MlsExtension},
14-
group::{
15-
mls_rules::{DefaultMlsRules, MlsRules},
16-
proposal::ProposalType,
17-
},
18-
identity::CredentialType,
19-
identity::SigningIdentity,
20-
protocol_version::ProtocolVersion,
21-
psk::{ExternalPskId, PreSharedKey},
22-
storage_provider::in_memory::{
23-
InMemoryGroupStateStorage, InMemoryKeyPackageStorage, InMemoryPreSharedKeyStorage,
24-
},
25-
tree_kem::{Capabilities, Lifetime},
26-
Sealed,
9+
use crate::cipher_suite::CipherSuite;
10+
use crate::client::Client;
11+
use crate::client_config::ClientConfig;
12+
use crate::extension::{ExtensionType, MlsExtension};
13+
use crate::group::mls_rules::{DefaultMlsRules, MlsRules};
14+
use crate::group::proposal::ProposalType;
15+
use crate::identity::{CredentialType, SigningIdentity};
16+
use crate::protocol_version::ProtocolVersion;
17+
use crate::psk::{ExternalPskId, PreSharedKey};
18+
use crate::storage_provider::in_memory::{
19+
InMemoryGroupStateStorage, InMemoryKeyPackageStorage, InMemoryPreSharedKeyStorage,
2720
};
21+
use crate::tree_kem::{Capabilities, Lifetime};
22+
use crate::Sealed;
2823

2924
#[cfg(feature = "std")]
3025
use crate::time::MlsTime;
@@ -927,11 +922,9 @@ pub(crate) fn recreate_config<T: ClientConfig>(
927922
/// Definitions meant to be private that are inaccessible outside this crate. They need to be marked
928923
/// `pub` because they appear in public definitions.
929924
mod private {
930-
use mls_rs_core::{
931-
crypto::{CipherSuite, SignatureSecretKey},
932-
identity::SigningIdentity,
933-
protocol_version::ProtocolVersion,
934-
};
925+
use mls_rs_core::crypto::{CipherSuite, SignatureSecretKey};
926+
use mls_rs_core::identity::SigningIdentity;
927+
use mls_rs_core::protocol_version::ProtocolVersion;
935928

936929
use crate::client_builder::{IntoConfigOutput, Settings};
937930

@@ -977,27 +970,21 @@ mod private {
977970
}
978971
}
979972

980-
use mls_rs_core::{
981-
crypto::{CryptoProvider, SignatureSecretKey},
982-
extension::{ExtensionError, ExtensionList},
983-
group::GroupStateStorage,
984-
identity::IdentityProvider,
985-
key_package::KeyPackageStorage,
986-
psk::PreSharedKeyStorage,
987-
};
973+
use mls_rs_core::crypto::{CryptoProvider, SignatureSecretKey};
974+
use mls_rs_core::extension::{ExtensionError, ExtensionList};
975+
use mls_rs_core::group::GroupStateStorage;
976+
use mls_rs_core::identity::IdentityProvider;
977+
use mls_rs_core::key_package::KeyPackageStorage;
978+
use mls_rs_core::psk::PreSharedKeyStorage;
988979
use private::{Config, ConfigInner, IntoConfig};
989980

990981
#[cfg(test)]
991982
pub(crate) mod test_utils {
992-
use crate::{
993-
client_builder::{BaseConfig, ClientBuilder, WithIdentityProvider},
994-
crypto::test_utils::TestCryptoProvider,
995-
identity::{
996-
basic::BasicIdentityProvider,
997-
test_utils::{get_test_signing_identity, BasicWithCustomProvider},
998-
},
999-
CipherSuite,
1000-
};
983+
use crate::client_builder::{BaseConfig, ClientBuilder, WithIdentityProvider};
984+
use crate::crypto::test_utils::TestCryptoProvider;
985+
use crate::identity::basic::BasicIdentityProvider;
986+
use crate::identity::test_utils::{get_test_signing_identity, BasicWithCustomProvider};
987+
use crate::CipherSuite;
1001988

1002989
use super::WithCryptoProvider;
1003990

mls-rs/src/client_config.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
// Copyright by contributors to this project.
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5-
use crate::{
6-
extension::ExtensionType,
7-
group::{mls_rules::MlsRules, proposal::ProposalType},
8-
identity::CredentialType,
9-
protocol_version::ProtocolVersion,
10-
tree_kem::{leaf_node::ConfigProperties, Capabilities, Lifetime},
11-
ExtensionList,
12-
};
5+
use crate::extension::ExtensionType;
6+
use crate::group::mls_rules::MlsRules;
7+
use crate::group::proposal::ProposalType;
8+
use crate::identity::CredentialType;
9+
use crate::protocol_version::ProtocolVersion;
10+
use crate::tree_kem::leaf_node::ConfigProperties;
11+
use crate::tree_kem::{Capabilities, Lifetime};
12+
use crate::ExtensionList;
1313
use alloc::vec::Vec;
14-
use mls_rs_core::{
15-
crypto::CryptoProvider, group::GroupStateStorage, identity::IdentityProvider,
16-
key_package::KeyPackageStorage, psk::PreSharedKeyStorage,
17-
};
14+
use mls_rs_core::crypto::CryptoProvider;
15+
use mls_rs_core::group::GroupStateStorage;
16+
use mls_rs_core::identity::IdentityProvider;
17+
use mls_rs_core::key_package::KeyPackageStorage;
18+
use mls_rs_core::psk::PreSharedKeyStorage;
1819

1920
pub trait ClientConfig: Send + Sync + Clone {
2021
type KeyPackageRepository: KeyPackageStorage + Clone;

mls-rs/src/extension/built_in.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use core::fmt::{self, Debug};
77
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
88
use mls_rs_core::extension::{ExtensionType, MlsCodecExtension};
99

10-
use mls_rs_core::{group::ProposalType, identity::CredentialType};
10+
use mls_rs_core::group::ProposalType;
11+
use mls_rs_core::identity::CredentialType;
1112

1213
#[cfg(feature = "by_ref_proposal")]
1314
use mls_rs_core::{

0 commit comments

Comments
 (0)