Skip to content

Commit 2d57060

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 2d57060

File tree

177 files changed

+1439
-1787
lines changed

Some content is hidden

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

177 files changed

+1439
-1787
lines changed

mls-rs-codec-derive/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
use std::str::FromStr;
66

7-
use darling::{
8-
ast::{self, Fields},
9-
FromDeriveInput, FromField, FromVariant,
10-
};
7+
use darling::ast::{self, Fields};
8+
use darling::{FromDeriveInput, FromField, FromVariant};
119
use proc_macro2::{Literal, TokenStream};
1210
use quote::quote;
1311
use syn::{

mls-rs-codec/src/byte_vec.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 crate::{iter::mls_decode_split_on_collection, Error, MlsEncode, MlsSize, VarInt};
5+
use crate::iter::mls_decode_split_on_collection;
6+
use crate::{Error, MlsEncode, MlsSize, VarInt};
67

78
use alloc::vec::Vec;
89

mls-rs-codec/src/cow.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use alloc::{
2-
borrow::{Cow, ToOwned},
3-
vec::Vec,
4-
};
1+
use alloc::borrow::{Cow, ToOwned};
2+
use alloc::vec::Vec;
53

64
use crate::{Error, MlsDecode, MlsEncode, MlsSize};
75

mls-rs-codec/src/map.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 alloc::{collections::BTreeMap, vec::Vec};
5+
use alloc::collections::BTreeMap;
6+
use alloc::vec::Vec;
67

78
#[cfg(feature = "std")]
89
use std::{collections::HashMap, hash::Hash};

mls-rs-codec/src/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{MlsDecode, MlsEncode, MlsSize};
2-
use alloc::{string::String, vec::Vec};
2+
use alloc::string::String;
3+
use alloc::vec::Vec;
34

45
impl MlsSize for str {
56
fn mls_encoded_len(&self) -> usize {

mls-rs-codec/src/vec.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ where
6464
#[cfg(test)]
6565
mod tests {
6666
use crate::{Error, MlsDecode, MlsEncode};
67-
use alloc::{vec, vec::Vec};
67+
use alloc::vec;
68+
use alloc::vec::Vec;
6869
use assert_matches::assert_matches;
6970

7071
#[cfg(target_arch = "wasm32")]

mls-rs-core/src/crypto.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
use crate::error::IntoAnyError;
66
use alloc::vec;
77
use alloc::vec::Vec;
8-
use core::{
9-
fmt::{self, Debug},
10-
ops::Deref,
11-
};
8+
use core::fmt::{self, Debug};
9+
use core::ops::Deref;
1210
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
1311
use zeroize::{ZeroizeOnDrop, Zeroizing};
1412

mls-rs-core/src/extension.rs

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

5-
use core::{
6-
fmt::{self, Debug},
7-
ops::Deref,
8-
};
5+
use core::fmt::{self, Debug};
6+
use core::ops::Deref;
97

108
use crate::error::{AnyError, IntoAnyError};
119
use alloc::vec::Vec;

mls-rs-core/src/extension/list.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ mod tests {
173173
use assert_matches::assert_matches;
174174
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
175175

176-
use crate::extension::{
177-
list::ExtensionList, Extension, ExtensionType, MlsCodecExtension, MlsExtension,
178-
};
176+
use crate::extension::list::ExtensionList;
177+
use crate::extension::{Extension, ExtensionType, MlsCodecExtension, MlsExtension};
179178

180179
#[derive(Debug, Clone, MlsSize, MlsEncode, MlsDecode, PartialEq, Eq)]
181180
struct TestExtensionA(u32);

mls-rs-core/src/group/roster.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use alloc::vec;
66
use alloc::vec::Vec;
77
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
88

9-
use crate::{
10-
crypto::CipherSuite,
11-
extension::{ExtensionList, ExtensionType},
12-
identity::{CredentialType, SigningIdentity},
13-
protocol_version::ProtocolVersion,
14-
};
9+
use crate::crypto::CipherSuite;
10+
use crate::extension::{ExtensionList, ExtensionType};
11+
use crate::identity::{CredentialType, SigningIdentity};
12+
use crate::protocol_version::ProtocolVersion;
1513

1614
use super::ProposalType;
1715

mls-rs-core/src/identity/basic.rs

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

5-
use core::{
6-
convert::Infallible,
7-
fmt::{self, Debug},
8-
};
5+
use core::convert::Infallible;
6+
use core::fmt::{self, Debug};
97

108
use alloc::vec::Vec;
119
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

mls-rs-core/src/identity/credential.rs

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

5-
use core::{
6-
fmt::{self, Debug},
7-
ops::Deref,
8-
};
5+
use core::fmt::{self, Debug};
6+
use core::ops::Deref;
97

108
use alloc::vec::Vec;
119
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

mls-rs-core/src/identity/provider.rs

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

5-
use crate::{error::IntoAnyError, extension::ExtensionList, time::MlsTime};
5+
use crate::error::IntoAnyError;
6+
use crate::extension::ExtensionList;
7+
use crate::time::MlsTime;
68
#[cfg(mls_build_async)]
79
use alloc::boxed::Box;
810
use alloc::vec::Vec;

mls-rs-core/src/identity/x509.rs

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

5-
use core::{
6-
convert::Infallible,
7-
fmt::{self, Debug},
8-
ops::{Deref, DerefMut},
9-
};
5+
use core::convert::Infallible;
6+
use core::fmt::{self, Debug};
7+
use core::ops::{Deref, DerefMut};
108

119
use alloc::vec::Vec;
1210
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

mls-rs-core/src/key_package.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use alloc::vec::Vec;
88
use core::fmt::{self, Debug};
99
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
1010

11-
use crate::{crypto::HpkeSecretKey, error::IntoAnyError};
11+
use crate::crypto::HpkeSecretKey;
12+
use crate::error::IntoAnyError;
1213

1314
#[derive(Clone, PartialEq, Eq, MlsEncode, MlsDecode, MlsSize)]
1415
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]

mls-rs-core/src/psk.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ use crate::error::IntoAnyError;
66
#[cfg(mls_build_async)]
77
use alloc::boxed::Box;
88
use alloc::vec::Vec;
9-
use core::{
10-
fmt::{self, Debug},
11-
ops::Deref,
12-
};
9+
use core::fmt::{self, Debug};
10+
use core::ops::Deref;
1311
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
1412
use zeroize::Zeroizing;
1513

mls-rs-core/src/secret.rs

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

55
use alloc::vec::Vec;
6-
use core::{
7-
fmt::{self, Debug},
8-
ops::{Deref, DerefMut},
9-
};
6+
use core::fmt::{self, Debug};
7+
use core::ops::{Deref, DerefMut};
108
use zeroize::Zeroizing;
119

1210
#[cfg_attr(

mls-rs-crypto-awslc/src/ec.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 std::{os::raw::c_void, ptr::null_mut};
5+
use std::os::raw::c_void;
6+
use std::ptr::null_mut;
67

78
use aws_lc_rs::error::Unspecified;
89
use aws_lc_sys::{

mls-rs-crypto-awslc/src/ecdsa.rs

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

5-
use std::{ffi::c_void, mem::MaybeUninit, ops::Deref, ptr::null_mut};
5+
use std::ffi::c_void;
6+
use std::mem::MaybeUninit;
7+
use std::ops::Deref;
8+
use std::ptr::null_mut;
69

7-
use aws_lc_rs::{
8-
digest,
9-
error::Unspecified,
10-
signature::{self, UnparsedPublicKey, ED25519_PUBLIC_KEY_LEN},
11-
};
10+
use aws_lc_rs::digest;
11+
use aws_lc_rs::error::Unspecified;
12+
use aws_lc_rs::signature::{self, UnparsedPublicKey, ED25519_PUBLIC_KEY_LEN};
1213

1314
use aws_lc_sys::{
1415
ECDSA_SIG_free, ECDSA_SIG_to_bytes, ECDSA_do_sign, ED25519_keypair, ED25519_sign,
@@ -18,11 +19,10 @@ use aws_lc_sys::{
1819
use mls_rs_core::crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey};
1920
use mls_rs_crypto_traits::Curve;
2021

21-
use crate::{
22-
check_non_null,
23-
ec::{ec_generate, ec_public_key, EcPrivateKey, EcPublicKey, EvpPkey, SUPPORTED_NIST_CURVES},
24-
AwsLcCryptoError,
22+
use crate::ec::{
23+
ec_generate, ec_public_key, EcPrivateKey, EcPublicKey, EvpPkey, SUPPORTED_NIST_CURVES,
2524
};
25+
use crate::{check_non_null, AwsLcCryptoError};
2626

2727
#[derive(Clone)]
2828
pub struct AwsLcEcdsa(Curve);

mls-rs-crypto-awslc/src/lib.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@ mod kdf;
99

1010
pub mod x509;
1111

12-
use std::{ffi::c_int, mem::MaybeUninit};
12+
use std::ffi::c_int;
13+
use std::mem::MaybeUninit;
1314

1415
use aead::AwsLcAead;
15-
use aws_lc_rs::{digest, error::Unspecified, hmac};
16+
use aws_lc_rs::error::Unspecified;
17+
use aws_lc_rs::{digest, hmac};
1618

1719
use aws_lc_sys::SHA256;
18-
use mls_rs_core::{
19-
crypto::{
20-
CipherSuite, CipherSuiteProvider, CryptoProvider, HpkeCiphertext, HpkePublicKey,
21-
HpkeSecretKey, SignaturePublicKey, SignatureSecretKey,
22-
},
23-
error::IntoAnyError,
20+
use mls_rs_core::crypto::{
21+
CipherSuite, CipherSuiteProvider, CryptoProvider, HpkeCiphertext, HpkePublicKey, HpkeSecretKey,
22+
SignaturePublicKey, SignatureSecretKey,
2423
};
24+
use mls_rs_core::error::IntoAnyError;
2525

2626
use ec::Ecdh;
2727
use ecdsa::AwsLcEcdsa;
2828
use kdf::AwsLcHkdf;
29-
use mls_rs_crypto_hpke::{
30-
context::{ContextR, ContextS},
31-
dhkem::DhKem,
32-
hpke::{Hpke, HpkeError},
33-
};
29+
use mls_rs_crypto_hpke::context::{ContextR, ContextS};
30+
use mls_rs_crypto_hpke::dhkem::DhKem;
31+
use mls_rs_crypto_hpke::hpke::{Hpke, HpkeError};
3432
use mls_rs_crypto_traits::{AeadType, KdfType, KemId};
3533
use thiserror::Error;
3634
use zeroize::Zeroizing;

mls-rs-crypto-awslc/src/x509/certificate.rs

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

5-
use std::{
6-
ffi::{c_long, c_void},
7-
mem,
8-
ptr::null_mut,
9-
time::Duration,
10-
};
5+
use std::ffi::{c_long, c_void};
6+
use std::mem;
7+
use std::ptr::null_mut;
8+
use std::time::Duration;
119

1210
use aws_lc_sys::{
1311
d2i_X509, i2d_X509, i2d_X509_NAME, ASN1_INTEGER_free, ASN1_INTEGER_to_BN, ASN1_TIME_free,
@@ -20,24 +18,18 @@ use aws_lc_sys::{
2018
X509_set_issuer_name, X509_set_notAfter, X509_set_notBefore, X509_set_pubkey,
2119
X509_set_serialNumber, X509_set_subject_name, X509_set_version, X509_sign, ASN1_TIME, X509,
2220
};
23-
use mls_rs_core::{
24-
crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey},
25-
time::MlsTime,
26-
};
21+
use mls_rs_core::crypto::{CipherSuite, SignaturePublicKey, SignatureSecretKey};
22+
use mls_rs_core::time::MlsTime;
2723
use mls_rs_identity_x509::{DerCertificate, SubjectAltName, SubjectComponent};
2824

29-
use crate::{
30-
check_int_return, check_non_null, check_non_null_const, check_res, ecdsa::AwsLcEcdsa,
31-
AwsLcCryptoError,
32-
};
25+
use crate::ecdsa::AwsLcEcdsa;
26+
use crate::{check_int_return, check_non_null, check_non_null_const, check_res, AwsLcCryptoError};
3327

34-
use super::{
35-
component::{
36-
components_from_name, GeneralName, Stack, StackItem, X509Extension, X509ExtensionContext,
37-
X509Name,
38-
},
39-
request::digest_for_curve,
28+
use super::component::{
29+
components_from_name, GeneralName, Stack, StackItem, X509Extension, X509ExtensionContext,
30+
X509Name,
4031
};
32+
use super::request::digest_for_curve;
4133

4234
pub struct Certificate(*mut X509);
4335

@@ -346,19 +338,16 @@ unsafe fn posix_to_asn1_time(time: MlsTime) -> Result<*mut ASN1_TIME, AwsLcCrypt
346338

347339
#[cfg(test)]
348340
mod tests {
349-
use mls_rs_core::{crypto::CipherSuite, time::MlsTime};
341+
use mls_rs_core::crypto::CipherSuite;
342+
use mls_rs_core::time::MlsTime;
350343
use mls_rs_identity_x509::{
351344
CertificateChain, SubjectAltName, SubjectComponent, X509CredentialValidator,
352345
};
353346

354-
use crate::{
355-
ecdsa::AwsLcEcdsa,
356-
x509::{
357-
component::{KeyUsage, X509Extension},
358-
test_utils::{test_root_ca, test_root_ca_key},
359-
CertificateValidator,
360-
},
361-
};
347+
use crate::ecdsa::AwsLcEcdsa;
348+
use crate::x509::component::{KeyUsage, X509Extension};
349+
use crate::x509::test_utils::{test_root_ca, test_root_ca_key};
350+
use crate::x509::CertificateValidator;
362351

363352
use super::Certificate;
364353

mls-rs-crypto-awslc/src/x509/component.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

55
use core::slice;
6-
use std::{
7-
ffi::{c_int, c_void, CString},
8-
marker::PhantomData,
9-
net::IpAddr,
10-
ptr::null_mut,
11-
};
6+
use std::ffi::{c_int, c_void, CString};
7+
use std::marker::PhantomData;
8+
use std::net::IpAddr;
9+
use std::ptr::null_mut;
1210

1311
use aws_lc_sys::{
1412
stack_st, ASN1_STRING_data, ASN1_STRING_free, ASN1_STRING_get0_data, ASN1_STRING_length,

mls-rs-crypto-awslc/src/x509/parser.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ mod tests {
5959
use mls_rs_core::crypto::CipherSuite;
6060
use mls_rs_identity_x509::{SubjectAltName, SubjectComponent, X509CertificateReader};
6161

62-
use crate::{
63-
ecdsa::AwsLcEcdsa,
64-
x509::{
65-
component::X509Name,
66-
test_utils::{load_github_leaf, load_ip_cert, load_test_ca, test_leaf, test_leaf_key},
67-
},
62+
use crate::ecdsa::AwsLcEcdsa;
63+
use crate::x509::component::X509Name;
64+
use crate::x509::test_utils::{
65+
load_github_leaf, load_ip_cert, load_test_ca, test_leaf, test_leaf_key,
6866
};
6967

7068
use super::CertificateParser;

0 commit comments

Comments
 (0)