From 0e9b64fb849b1a14afcc5ef327d28ca2f956629b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 22 Jan 2024 15:32:13 +0100 Subject: [PATCH] Wrap rust comments (#512) Add a `rustfmt.toml` config with the following options: - comment_width: 100 - wrap_comments: true - group_imports: "StdExternalCrate" - imports_granularity: "Crate" This sorts and groups imports. And wraps long comments. Unfortunately all of these configs are "unstable" and we need nightly cargo-fmt in order to run them. --- .github/workflows/lint.yml | 7 ++++++- .../src/apis/access_policies_api.rs | 9 ++++++--- .../src/apis/collections_api.rs | 6 ++++-- .../bitwarden-api-api/src/apis/groups_api.rs | 3 ++- .../src/apis/organization_connections_api.rs | 6 ++++-- .../src/apis/organization_sponsorships_api.rs | 12 +++++++---- .../src/apis/organization_users_api.rs | 9 ++++++--- ...lf_hosted_organization_sponsorships_api.rs | 9 ++++++--- .../src/models/sso_configuration_data.rs | 5 ++++- crates/bitwarden-crypto/src/aes.rs | 3 ++- .../src/enc_string/asymmetric.rs | 17 ++++++++-------- .../src/enc_string/symmetric.rs | 6 +++--- .../src/keys/shareable_key.rs | 3 ++- crates/bitwarden-generators/src/passphrase.rs | 12 +++++++---- crates/bitwarden-generators/src/password.rs | 9 ++++++--- crates/bitwarden-json/src/command.rs | 20 ++----------------- crates/bitwarden-napi/src/client.rs | 3 ++- crates/bitwarden-uniffi/src/crypto.rs | 14 ++++++++----- crates/bitwarden-uniffi/src/error.rs | 3 ++- crates/bitwarden-wasm/src/client.rs | 4 ++-- crates/bitwarden/src/admin_console/policy.rs | 14 +++++++------ crates/bitwarden/src/auth/login/password.rs | 6 ++++-- crates/bitwarden/src/client/access_token.rs | 3 ++- .../bitwarden/src/client/client_settings.rs | 4 ++-- .../src/client/encryption_settings.rs | 10 ++++++---- crates/bitwarden/src/lib.rs | 1 - crates/bitwarden/src/mobile/crypto.rs | 3 ++- .../bitwarden/src/mobile/vault/client_totp.rs | 1 - .../platform/secret_verification_request.rs | 9 +++++---- crates/bitwarden/src/platform/sync.rs | 3 ++- crates/bitwarden/src/tool/client_generator.rs | 15 +++++++------- .../bitwarden/src/vault/cipher/attachment.rs | 7 +++---- crates/bitwarden/src/vault/cipher/cipher.rs | 3 ++- crates/bitwarden/src/vault/send.rs | 15 ++++++++------ crates/bitwarden/src/vault/totp.rs | 3 ++- crates/bws/src/render.rs | 6 ++++-- crates/sdk-schemas/src/main.rs | 8 +++++--- rustfmt.toml | 7 +++++++ 38 files changed, 164 insertions(+), 114 deletions(-) create mode 100644 rustfmt.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dbf357d3b..2f8989f91 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,11 +24,16 @@ jobs: with: toolchain: stable + - name: Install rust nightly + run: | + rustup toolchain install nightly + rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu + - name: Cache cargo registry uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 - name: Cargo fmt - run: cargo fmt --check + run: cargo +nightly fmt --check - name: Set up Node uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 diff --git a/crates/bitwarden-api-api/src/apis/access_policies_api.rs b/crates/bitwarden-api-api/src/apis/access_policies_api.rs index 7e538c0b4..9eb40719d 100644 --- a/crates/bitwarden-api-api/src/apis/access_policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/access_policies_api.rs @@ -27,21 +27,24 @@ pub enum AccessPoliciesIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_access_policies_people_potential_grantees_get`] +/// struct for typed errors of method +/// [`organizations_id_access_policies_people_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_access_policies_projects_potential_grantees_get`] +/// struct for typed errors of method +/// [`organizations_id_access_policies_projects_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_access_policies_service_accounts_potential_grantees_get`] +/// struct for typed errors of method +/// [`organizations_id_access_policies_service_accounts_potential_grantees_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError { diff --git a/crates/bitwarden-api-api/src/apis/collections_api.rs b/crates/bitwarden-api-api/src/apis/collections_api.rs index 02ac6eb16..c95ac5529 100644 --- a/crates/bitwarden-api-api/src/apis/collections_api.rs +++ b/crates/bitwarden-api-api/src/apis/collections_api.rs @@ -62,7 +62,8 @@ pub enum OrganizationsOrgIdCollectionsIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_delete_user_org_user_id_post`] +/// struct for typed errors of method +/// [`organizations_org_id_collections_id_delete_user_org_user_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdDeleteUserOrgUserIdPostError { @@ -97,7 +98,8 @@ pub enum OrganizationsOrgIdCollectionsIdPutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_collections_id_user_org_user_id_delete`] +/// struct for typed errors of method +/// [`organizations_org_id_collections_id_user_org_user_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdCollectionsIdUserOrgUserIdDeleteError { diff --git a/crates/bitwarden-api-api/src/apis/groups_api.rs b/crates/bitwarden-api-api/src/apis/groups_api.rs index 46ed9afa5..d52fcd200 100644 --- a/crates/bitwarden-api-api/src/apis/groups_api.rs +++ b/crates/bitwarden-api-api/src/apis/groups_api.rs @@ -48,7 +48,8 @@ pub enum OrganizationsOrgIdGroupsIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_groups_id_delete_user_org_user_id_post`] +/// struct for typed errors of method +/// [`organizations_org_id_groups_id_delete_user_org_user_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdGroupsIdDeleteUserOrgUserIdPostError { diff --git a/crates/bitwarden-api-api/src/apis/organization_connections_api.rs b/crates/bitwarden-api-api/src/apis/organization_connections_api.rs index 8bf41ffd1..ee75716dc 100644 --- a/crates/bitwarden-api-api/src/apis/organization_connections_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_connections_api.rs @@ -20,14 +20,16 @@ pub enum OrganizationsConnectionsEnabledGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_connections_organization_connection_id_delete`] +/// struct for typed errors of method +/// [`organizations_connections_organization_connection_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_connections_organization_connection_id_delete_post`] +/// struct for typed errors of method +/// [`organizations_connections_organization_connection_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsConnectionsOrganizationConnectionIdDeletePostError { diff --git a/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs b/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs index 203174fdf..e3f1ccf24 100644 --- a/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_sponsorships_api.rs @@ -27,21 +27,24 @@ pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError { @@ -62,7 +65,8 @@ pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_sponsoring_organization_id_delete_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_sponsoring_organization_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSponsoringOrganizationIdDeletePostError { diff --git a/crates/bitwarden-api-api/src/apis/organization_users_api.rs b/crates/bitwarden-api-api/src/apis/organization_users_api.rs index 5a8e99916..804a29019 100644 --- a/crates/bitwarden-api-api/src/apis/organization_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_users_api.rs @@ -174,14 +174,16 @@ pub enum OrganizationsOrgIdUsersInvitePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_organization_user_id_accept_init_post`] +/// struct for typed errors of method +/// [`organizations_org_id_users_organization_user_id_accept_init_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_organization_user_id_accept_post`] +/// struct for typed errors of method +/// [`organizations_org_id_users_organization_user_id_accept_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptPostError { @@ -230,7 +232,8 @@ pub enum OrganizationsOrgIdUsersRevokePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_org_id_users_user_id_reset_password_enrollment_put`] +/// struct for typed errors of method +/// [`organizations_org_id_users_user_id_reset_password_enrollment_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError { diff --git a/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs b/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs index dc2da4103..60b8a6d28 100644 --- a/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs +++ b/crates/bitwarden-api-api/src/apis/self_hosted_organization_sponsorships_api.rs @@ -13,21 +13,24 @@ use reqwest; use super::{configuration, Error}; use crate::apis::ResponseContent; -/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`] +/// struct for typed errors of method +/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`] +/// struct for typed errors of method +/// [`organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError { diff --git a/crates/bitwarden-api-api/src/models/sso_configuration_data.rs b/crates/bitwarden-api-api/src/models/sso_configuration_data.rs index 0e2890ad9..2d898488e 100644 --- a/crates/bitwarden-api-api/src/models/sso_configuration_data.rs +++ b/crates/bitwarden-api-api/src/models/sso_configuration_data.rs @@ -17,7 +17,10 @@ pub struct SsoConfigurationData { skip_serializing_if = "Option::is_none" )] pub member_decryption_type: Option, - /// Legacy property to determine if KeyConnector was enabled. Kept for backwards compatibility with old configs that will not have the new Bit.Core.Auth.Models.Data.SsoConfigurationData.MemberDecryptionType when deserialized from the database. + /// Legacy property to determine if KeyConnector was enabled. Kept for backwards compatibility + /// with old configs that will not have the new + /// Bit.Core.Auth.Models.Data.SsoConfigurationData.MemberDecryptionType when deserialized from + /// the database. #[serde( rename = "keyConnectorEnabled", skip_serializing_if = "Option::is_none" diff --git a/crates/bitwarden-crypto/src/aes.rs b/crates/bitwarden-crypto/src/aes.rs index cb4bf3102..e948fdc18 100644 --- a/crates/bitwarden-crypto/src/aes.rs +++ b/crates/bitwarden-crypto/src/aes.rs @@ -32,7 +32,8 @@ pub(crate) fn decrypt_aes256( .decrypt_padded_mut::(&mut data) .map_err(|_| CryptoError::KeyDecrypt)?; - // Data is decrypted in place and returns a subslice of the original Vec, to avoid cloning it, we truncate to the subslice length + // Data is decrypted in place and returns a subslice of the original Vec, to avoid cloning it, + // we truncate to the subslice length let decrypted_len = decrypted_key_slice.len(); data.truncate(decrypted_len); diff --git a/crates/bitwarden-crypto/src/enc_string/asymmetric.rs b/crates/bitwarden-crypto/src/enc_string/asymmetric.rs index 4c1dc3c8c..81ac81a5b 100644 --- a/crates/bitwarden-crypto/src/enc_string/asymmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/asymmetric.rs @@ -12,12 +12,12 @@ use crate::{ /// # Encrypted string primitive /// -/// [AsymmetricEncString] is a Bitwarden specific primitive that represents an asymmetrically encrypted string. -/// They are used together with the KeyDecryptable and KeyEncryptable traits to encrypt and decrypt data using -/// [AsymmetricCryptoKey]s. +/// [AsymmetricEncString] is a Bitwarden specific primitive that represents an asymmetrically +/// encrypted string. They are used together with the KeyDecryptable and KeyEncryptable traits to +/// encrypt and decrypt data using [AsymmetricCryptoKey]s. /// -/// The flexibility of the [AsymmetricEncString] type allows for different encryption algorithms to be used -/// which is represented by the different variants of the enum. +/// The flexibility of the [AsymmetricEncString] type allows for different encryption algorithms to +/// be used which is represented by the different variants of the enum. /// /// ## Note /// @@ -30,8 +30,8 @@ use crate::{ /// /// ## Serialization /// -/// [AsymmetricEncString] implements [Display] and [FromStr] to allow for easy serialization and uses a -/// custom scheme to represent the different variants. +/// [AsymmetricEncString] implements [Display] and [FromStr] to allow for easy serialization and +/// uses a custom scheme to represent the different variants. /// /// The scheme is one of the following schemes: /// - `[type].[data]` @@ -54,7 +54,8 @@ pub enum AsymmetricEncString { Rsa2048_OaepSha1_HmacSha256_B64 { data: Vec, mac: Vec }, } -/// To avoid printing sensitive information, [AsymmetricEncString] debug prints to `AsymmetricEncString`. +/// To avoid printing sensitive information, [AsymmetricEncString] debug prints to +/// `AsymmetricEncString`. impl std::fmt::Debug for AsymmetricEncString { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("AsymmetricEncString").finish() diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index d6dd44374..25a0a8280 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -12,9 +12,9 @@ use crate::{ /// # Encrypted string primitive /// -/// [EncString] is a Bitwarden specific primitive that represents a symmetrically encrypted string. They are -/// are used together with the [KeyDecryptable] and [KeyEncryptable] traits to encrypt and decrypt -/// data using [SymmetricCryptoKey]s. +/// [EncString] is a Bitwarden specific primitive that represents a symmetrically encrypted string. +/// They are are used together with the [KeyDecryptable] and [KeyEncryptable] traits to encrypt and +/// decrypt data using [SymmetricCryptoKey]s. /// /// The flexibility of the [EncString] type allows for different encryption algorithms to be used /// which is represented by the different variants of the enum. diff --git a/crates/bitwarden-crypto/src/keys/shareable_key.rs b/crates/bitwarden-crypto/src/keys/shareable_key.rs index a13f17155..eb5353401 100644 --- a/crates/bitwarden-crypto/src/keys/shareable_key.rs +++ b/crates/bitwarden-crypto/src/keys/shareable_key.rs @@ -14,7 +14,8 @@ pub fn derive_shareable_key( ) -> SymmetricCryptoKey { // Because all inputs are fixed size, we can unwrap all errors here without issue - // TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends + // TODO: Are these the final `key` and `info` parameters or should we change them? I followed + // the pattern used for sends let res = Hmac::::new_from_slice(format!("bitwarden-{}", name).as_bytes()) .unwrap() .chain_update(secret) diff --git a/crates/bitwarden-generators/src/passphrase.rs b/crates/bitwarden-generators/src/passphrase.rs index 4094e4b70..f8329a80c 100644 --- a/crates/bitwarden-generators/src/passphrase.rs +++ b/crates/bitwarden-generators/src/passphrase.rs @@ -26,7 +26,8 @@ pub struct PassphraseGeneratorRequest { pub word_separator: String, /// When set to true, capitalize the first letter of each word in the generated passphrase. pub capitalize: bool, - /// When set to true, include a number at the end of one of the words in the generated passphrase. + /// When set to true, include a number at the end of one of the words in the generated + /// passphrase. pub include_number: bool, } @@ -45,7 +46,8 @@ const MINIMUM_PASSPHRASE_NUM_WORDS: u8 = 3; const MAXIMUM_PASSPHRASE_NUM_WORDS: u8 = 20; /// Represents a set of valid options to generate a passhprase with. -/// To get an instance of it, use [`PassphraseGeneratorRequest::validate_options`](PassphraseGeneratorRequest::validate_options) +/// To get an instance of it, use +/// [`PassphraseGeneratorRequest::validate_options`](PassphraseGeneratorRequest::validate_options) struct ValidPassphraseGeneratorOptions { pub(super) num_words: u8, pub(super) word_separator: String, @@ -54,7 +56,8 @@ struct ValidPassphraseGeneratorOptions { } impl PassphraseGeneratorRequest { - /// Validates the request and returns an immutable struct with valid options to use with the passphrase generator. + /// Validates the request and returns an immutable struct with valid options to use with the + /// passphrase generator. fn validate_options(self) -> Result { // TODO: Add password generator policy checks @@ -173,7 +176,8 @@ mod tests { let input = PassphraseGeneratorRequest { num_words: 4, - word_separator: "👨🏻‍❤️‍💋‍👨🏻".into(), // This emoji is 35 bytes long, but represented as a single character + word_separator: "👨🏻‍❤️‍💋‍👨🏻".into(), /* This emoji is 35 bytes long, but represented + * as a single character */ capitalize: false, include_number: true, } diff --git a/crates/bitwarden-generators/src/password.rs b/crates/bitwarden-generators/src/password.rs index c7a8fc252..6cab6dd65 100644 --- a/crates/bitwarden-generators/src/password.rs +++ b/crates/bitwarden-generators/src/password.rs @@ -85,7 +85,8 @@ impl CharSet { self.include_if(true, other) } - /// Includes the given characters in the set if the predicate is true. Any duplicate items will be ignored + /// Includes the given characters in the set if the predicate is true. Any duplicate items will + /// be ignored pub fn include_if(mut self, predicate: bool, other: impl IntoIterator) -> Self { if predicate { self.0.extend(other); @@ -122,7 +123,8 @@ impl Distribution for CharSet { } /// Represents a set of valid options to generate a password with. -/// To get an instance of it, use [`PasswordGeneratorRequest::validate_options`](PasswordGeneratorRequest::validate_options) +/// To get an instance of it, use +/// [`PasswordGeneratorRequest::validate_options`](PasswordGeneratorRequest::validate_options) struct PasswordGeneratorOptions { pub(super) lower: (CharSet, usize), pub(super) upper: (CharSet, usize), @@ -134,7 +136,8 @@ struct PasswordGeneratorOptions { } impl PasswordGeneratorRequest { - /// Validates the request and returns an immutable struct with valid options to use with the password generator. + /// Validates the request and returns an immutable struct with valid options to use with the + /// password generator. fn validate_options(self) -> Result { // TODO: Add password generator policy checks diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 855a30399..8da5e8cbd 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -33,7 +33,6 @@ pub enum Command { /// This command is not capable of handling authentication requiring 2fa or captcha. /// /// Returns: [PasswordLoginResponse](bitwarden::auth::login::PasswordLoginResponse) - /// PasswordLogin(PasswordLoginRequest), #[cfg(feature = "internal")] @@ -42,7 +41,6 @@ pub enum Command { /// This command is for initiating an authentication handshake with Bitwarden. /// /// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse) - /// ApiKeyLogin(ApiKeyLoginRequest), #[cfg(feature = "secrets")] @@ -51,7 +49,6 @@ pub enum Command { /// This command is for initiating an authentication handshake with Bitwarden. /// /// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse) - /// AccessTokenLogin(AccessTokenLoginRequest), #[cfg(feature = "internal")] @@ -59,14 +56,12 @@ pub enum Command { /// Get the API key of the currently authenticated user /// /// Returns: [UserApiKeyResponse](bitwarden::platform::UserApiKeyResponse) - /// GetUserApiKey(SecretVerificationRequest), #[cfg(feature = "internal")] /// Get the user's passphrase /// /// Returns: String - /// Fingerprint(FingerprintRequest), #[cfg(feature = "internal")] @@ -74,7 +69,6 @@ pub enum Command { /// Retrieve all user data, ciphers and organizations the user is a part of /// /// Returns: [SyncResponse](bitwarden::platform::SyncResponse) - /// Sync(SyncRequest), #[cfg(feature = "secrets")] @@ -92,7 +86,6 @@ pub enum SecretsCommand { /// Retrieve a secret by the provided identifier /// /// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse) - /// Get(SecretGetRequest), /// > Requires Authentication @@ -100,7 +93,6 @@ pub enum SecretsCommand { /// Retrieve secrets by the provided identifiers /// /// Returns: [SecretsResponse](bitwarden::secrets_manager::secrets::SecretsResponse) - /// GetByIds(SecretsGetRequest), /// > Requires Authentication @@ -108,15 +100,14 @@ pub enum SecretsCommand { /// Creates a new secret in the provided organization using the given data /// /// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse) - /// Create(SecretCreateRequest), /// > Requires Authentication /// > Requires using an Access Token for login or calling Sync at least once - /// Lists all secret identifiers of the given organization, to then retrieve each secret, use `CreateSecret` + /// Lists all secret identifiers of the given organization, to then retrieve each secret, use + /// `CreateSecret` /// /// Returns: [SecretIdentifiersResponse](bitwarden::secrets_manager::secrets::SecretIdentifiersResponse) - /// List(SecretIdentifiersRequest), /// > Requires Authentication @@ -124,7 +115,6 @@ pub enum SecretsCommand { /// Updates an existing secret with the provided ID using the given data /// /// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse) - /// Update(SecretPutRequest), /// > Requires Authentication @@ -132,7 +122,6 @@ pub enum SecretsCommand { /// Deletes all the secrets whose IDs match the provided ones /// /// Returns: [SecretsDeleteResponse](bitwarden::secrets_manager::secrets::SecretsDeleteResponse) - /// Delete(SecretsDeleteRequest), } @@ -145,7 +134,6 @@ pub enum ProjectsCommand { /// Retrieve a project by the provided identifier /// /// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse) - /// Get(ProjectGetRequest), /// > Requires Authentication @@ -153,7 +141,6 @@ pub enum ProjectsCommand { /// Creates a new project in the provided organization using the given data /// /// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse) - /// Create(ProjectCreateRequest), /// > Requires Authentication @@ -161,7 +148,6 @@ pub enum ProjectsCommand { /// Lists all projects of the given organization /// /// Returns: [ProjectsResponse](bitwarden::secrets_manager::projects::ProjectsResponse) - /// List(ProjectsListRequest), /// > Requires Authentication @@ -169,7 +155,6 @@ pub enum ProjectsCommand { /// Updates an existing project with the provided ID using the given data /// /// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse) - /// Update(ProjectPutRequest), /// > Requires Authentication @@ -177,6 +162,5 @@ pub enum ProjectsCommand { /// Deletes all the projects whose IDs match the provided ones /// /// Returns: [ProjectsDeleteResponse](bitwarden::secrets_manager::projects::ProjectsDeleteResponse) - /// Delete(ProjectsDeleteRequest), } diff --git a/crates/bitwarden-napi/src/client.rs b/crates/bitwarden-napi/src/client.rs index d794b18f4..712cd4ffd 100644 --- a/crates/bitwarden-napi/src/client.rs +++ b/crates/bitwarden-napi/src/client.rs @@ -29,7 +29,8 @@ pub struct BitwardenClient(JsonClient); impl BitwardenClient { #[napi(constructor)] pub fn new(settings_input: Option, log_level: Option) -> Self { - // This will only fail if another logger was already initialized, so we can ignore the result + // This will only fail if another logger was already initialized, so we can ignore the + // result let _ = env_logger::Builder::from_default_env() .filter_level(convert_level(log_level.unwrap_or(LogLevel::Info))) .try_init(); diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index e54aae435..92afcbb87 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -12,7 +12,8 @@ pub struct ClientCrypto(pub(crate) Arc); #[uniffi::export(async_runtime = "tokio")] impl ClientCrypto { - /// Initialization method for the user crypto. Needs to be called before any other crypto operations. + /// Initialization method for the user crypto. Needs to be called before any other crypto + /// operations. pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { Ok(self .0 @@ -24,7 +25,8 @@ impl ClientCrypto { .await?) } - /// Initialization method for the organization crypto. Needs to be called after `initialize_user_crypto` but before any other crypto operations. + /// Initialization method for the organization crypto. Needs to be called after + /// `initialize_user_crypto` but before any other crypto operations. pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { Ok(self .0 @@ -49,13 +51,15 @@ impl ClientCrypto { .await?) } - /// Generates a PIN protected user key from the provided PIN. The result can be stored and later used - /// to initialize another client instance by using the PIN and the PIN key with `initialize_user_crypto`. + /// Generates a PIN protected user key from the provided PIN. The result can be stored and later + /// used to initialize another client instance by using the PIN and the PIN key with + /// `initialize_user_crypto`. pub async fn derive_pin_key(&self, pin: String) -> Result { Ok(self.0 .0.write().await.crypto().derive_pin_key(pin).await?) } - /// Derives the pin protected user key from encrypted pin. Used when pin requires master password on first unlock. + /// Derives the pin protected user key from encrypted pin. Used when pin requires master + /// password on first unlock. pub async fn derive_pin_user_key(&self, encrypted_pin: EncString) -> Result { Ok(self .0 diff --git a/crates/bitwarden-uniffi/src/error.rs b/crates/bitwarden-uniffi/src/error.rs index b6175eb3b..5eef9bbd5 100644 --- a/crates/bitwarden-uniffi/src/error.rs +++ b/crates/bitwarden-uniffi/src/error.rs @@ -1,6 +1,7 @@ use std::fmt::{Display, Formatter}; -// Name is converted from *Error to *Exception, so we can't just name the enum Error because Exception already exists +// Name is converted from *Error to *Exception, so we can't just name the enum Error because +// Exception already exists #[derive(uniffi::Error, Debug)] #[uniffi(flat_error)] pub enum BitwardenError { diff --git a/crates/bitwarden-wasm/src/client.rs b/crates/bitwarden-wasm/src/client.rs index 7d3d991db..b9f6723a6 100644 --- a/crates/bitwarden-wasm/src/client.rs +++ b/crates/bitwarden-wasm/src/client.rs @@ -26,8 +26,8 @@ fn convert_level(level: LogLevel) -> Level { } } -// Rc> is to avoid needing to take ownership of the Client during our async run_command function -// https://github.com/rustwasm/wasm-bindgen/issues/2195#issuecomment-799588401 +// Rc> is to avoid needing to take ownership of the Client during our async run_command +// function https://github.com/rustwasm/wasm-bindgen/issues/2195#issuecomment-799588401 #[wasm_bindgen] pub struct BitwardenClient(Rc>); diff --git a/crates/bitwarden/src/admin_console/policy.rs b/crates/bitwarden/src/admin_console/policy.rs index 1b4acc310..9a4b0d16f 100644 --- a/crates/bitwarden/src/admin_console/policy.rs +++ b/crates/bitwarden/src/admin_console/policy.rs @@ -20,18 +20,20 @@ pub struct Policy { #[derive(Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] pub enum PolicyType { - TwoFactorAuthentication = 0, // Requires users to have 2fa enabled - MasterPassword = 1, // Sets minimum requirements for master password complexity - PasswordGenerator = 2, // Sets minimum requirements/default type for generated passwords/passphrases + TwoFactorAuthentication = 0, // Requires users to have 2fa enabled + MasterPassword = 1, // Sets minimum requirements for master password complexity + PasswordGenerator = 2, /* Sets minimum requirements/default type for generated + * passwords/passphrases */ SingleOrg = 3, // Allows users to only be apart of one organization RequireSso = 4, // Requires users to authenticate with SSO PersonalOwnership = 5, // Disables personal vault ownership for adding/cloning items DisableSend = 6, // Disables the ability to create and edit Bitwarden Sends SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends - ResetPassword = 8, // Allows orgs to use reset password : also can enable auto-enrollment during invite flow - MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout + ResetPassword = 8, /* Allows orgs to use reset password : also can enable + * auto-enrollment during invite flow */ + MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout DisablePersonalVaultExport = 10, // Disable personal vault export - ActivateAutofill = 11, // Activates autofill with page load on the browser extension + ActivateAutofill = 11, // Activates autofill with page load on the browser extension } impl TryFrom for Policy { diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden/src/auth/login/password.rs index e5d579aa2..f873ace97 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden/src/auth/login/password.rs @@ -94,9 +94,11 @@ pub struct PasswordLoginResponse { pub reset_master_password: bool, /// Whether or not the user is required to update their master password pub force_password_reset: bool, - /// The available two factor authentication options. Present only when authentication fails due to requiring a second authentication factor. + /// The available two factor authentication options. Present only when authentication fails due + /// to requiring a second authentication factor. pub two_factor: Option, - /// The information required to present the user with a captcha challenge. Only present when authentication fails due to requiring validation of a captcha challenge. + /// The information required to present the user with a captcha challenge. Only present when + /// authentication fails due to requiring validation of a captcha challenge. pub captcha: Option, } diff --git a/crates/bitwarden/src/client/access_token.rs b/crates/bitwarden/src/client/access_token.rs index 4a6d5ed8c..d7cad2fca 100644 --- a/crates/bitwarden/src/client/access_token.rs +++ b/crates/bitwarden/src/client/access_token.rs @@ -88,7 +88,8 @@ mod tests { use crate::client::AccessToken; - // Encryption key without base64 padding, we generate it with padding but ignore it when decoding + // Encryption key without base64 padding, we generate it with padding but ignore it when + // decoding let t = "0.ec2c1d46-6a4b-4751-a310-af9601317f2d.C2IgxjjLF7qSshsbwe8JGcbM075YXw:X8vbvA0bduihIDe/qrzIQQ"; assert!(AccessToken::from_str(t).is_ok()); diff --git a/crates/bitwarden/src/client/client_settings.rs b/crates/bitwarden/src/client/client_settings.rs index 172baf733..2f0637b4a 100644 --- a/crates/bitwarden/src/client/client_settings.rs +++ b/crates/bitwarden/src/client/client_settings.rs @@ -1,8 +1,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -/// Basic client behavior settings. These settings specify the various targets and behavior of the Bitwarden Client. -/// They are optional and uneditable once the client is initialized. +/// Basic client behavior settings. These settings specify the various targets and behavior of the +/// Bitwarden Client. They are optional and uneditable once the client is initialized. /// /// Defaults to /// diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index c8126b4fe..8b4c5197e 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -45,9 +45,10 @@ impl EncryptionSettings { } } - /// Initialize the encryption settings with the decrypted user key and the encrypted user private key - /// This should only be used when unlocking the vault via biometrics or when the vault is set to lock: "never" - /// Otherwise handling the decrypted user key is dangerous and discouraged + /// Initialize the encryption settings with the decrypted user key and the encrypted user + /// private key This should only be used when unlocking the vault via biometrics or when the + /// vault is set to lock: "never" Otherwise handling the decrypted user key is dangerous and + /// discouraged #[cfg(feature = "internal")] pub(crate) fn new_decrypted_key( user_key: SymmetricCryptoKey, @@ -105,7 +106,8 @@ impl EncryptionSettings { } pub(crate) fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { - // If we don't have a private key set (to decode multiple org keys), we just use the main user key + // If we don't have a private key set (to decode multiple org keys), we just use the main + // user key if self.private_key.is_none() { return Some(&self.user_key); } diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index 5468be855..28eb521de 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -46,7 +46,6 @@ //! Ok(()) //! } //! ``` -//! #[cfg(feature = "mobile")] uniffi::setup_scaffolding!(); diff --git a/crates/bitwarden/src/mobile/crypto.rs b/crates/bitwarden/src/mobile/crypto.rs index c32a1d1d8..f88b3d3e6 100644 --- a/crates/bitwarden/src/mobile/crypto.rs +++ b/crates/bitwarden/src/mobile/crypto.rs @@ -47,7 +47,8 @@ pub enum InitUserCryptoMethod { Pin { /// The user's PIN pin: String, - /// The user's symmetric crypto key, encrypted with the PIN. Use `derive_pin_key` to obtain this. + /// The user's symmetric crypto key, encrypted with the PIN. Use `derive_pin_key` to obtain + /// this. pin_protected_user_key: EncString, }, } diff --git a/crates/bitwarden/src/mobile/vault/client_totp.rs b/crates/bitwarden/src/mobile/vault/client_totp.rs index 1d4ffd486..3d3b80f98 100644 --- a/crates/bitwarden/src/mobile/vault/client_totp.rs +++ b/crates/bitwarden/src/mobile/vault/client_totp.rs @@ -13,7 +13,6 @@ impl<'a> ClientVault<'a> { /// - A base32 encoded string /// - OTP Auth URI /// - Steam URI - /// pub fn generate_totp( &'a self, key: String, diff --git a/crates/bitwarden/src/platform/secret_verification_request.rs b/crates/bitwarden/src/platform/secret_verification_request.rs index b501d0181..e05926620 100644 --- a/crates/bitwarden/src/platform/secret_verification_request.rs +++ b/crates/bitwarden/src/platform/secret_verification_request.rs @@ -4,10 +4,11 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretVerificationRequest { - /// The user's master password to use for user verification. If supplied, this will be used for verification - /// purposes. + /// The user's master password to use for user verification. If supplied, this will be used for + /// verification purposes. pub master_password: Option, - /// Alternate user verification method through OTP. This is provided for users who have no master password due to - /// use of Customer Managed Encryption. Must be present and valid if master_password is absent. + /// Alternate user verification method through OTP. This is provided for users who have no + /// master password due to use of Customer Managed Encryption. Must be present and valid if + /// master_password is absent. pub otp: Option, } diff --git a/crates/bitwarden/src/platform/sync.rs b/crates/bitwarden/src/platform/sync.rs index 870b88ab9..c1a039137 100644 --- a/crates/bitwarden/src/platform/sync.rs +++ b/crates/bitwarden/src/platform/sync.rs @@ -69,7 +69,8 @@ pub struct DomainResponse { #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SyncResponse { - /// Data about the user, including their encryption keys and the organizations they are a part of + /// Data about the user, including their encryption keys and the organizations they are a part + /// of pub profile: ProfileResponse, pub folders: Vec, pub collections: Vec, diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden/src/tool/client_generator.rs index c21eeb929..16c786f9b 100644 --- a/crates/bitwarden/src/tool/client_generator.rs +++ b/crates/bitwarden/src/tool/client_generator.rs @@ -1,11 +1,11 @@ use bitwarden_generators::{passphrase, password, username}; -use crate::generators::{ - PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest, +use crate::{ + error::Result, + generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest}, + Client, }; -use crate::{error::Result, Client}; - pub struct ClientGenerator<'a> { pub(crate) client: &'a crate::Client, } @@ -62,10 +62,11 @@ impl<'a> ClientGenerator<'a> { } /// Generates a random username. - /// There are different username generation strategies, which can be customized using the `input` parameter. + /// There are different username generation strategies, which can be customized using the + /// `input` parameter. /// - /// Note that most generation strategies will be executed on the client side, but `Forwarded` will use third-party - /// services, which may require a specific setup or API key. + /// Note that most generation strategies will be executed on the client side, but `Forwarded` + /// will use third-party services, which may require a specific setup or API key. /// /// ``` /// use bitwarden::{Client, generators::{UsernameGeneratorRequest}, error::Result}; diff --git a/crates/bitwarden/src/vault/cipher/attachment.rs b/crates/bitwarden/src/vault/cipher/attachment.rs index 3e1e47025..40f32dcfb 100644 --- a/crates/bitwarden/src/vault/cipher/attachment.rs +++ b/crates/bitwarden/src/vault/cipher/attachment.rs @@ -4,9 +4,8 @@ use bitwarden_crypto::{ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{Error, Result}; - use super::Cipher; +use crate::error::{Error, Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -63,7 +62,8 @@ impl<'a> KeyEncryptable for Attachm let mut attachment = self.attachment; - // Because this is a new attachment, we have to generate a key for it, encrypt the contents with it, and then encrypt the key with the cipher key + // Because this is a new attachment, we have to generate a key for it, encrypt the contents + // with it, and then encrypt the key with the cipher key let attachment_key = SymmetricCryptoKey::generate(rand::thread_rng()); let encrypted_contents = self.contents.encrypt_with_key(&attachment_key)?; attachment.key = Some(attachment_key.to_vec().encrypt_with_key(ciphers_key)?); @@ -136,7 +136,6 @@ impl TryFrom for Attachment #[cfg(test)] mod tests { use base64::{engine::general_purpose::STANDARD, Engine}; - use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; use crate::vault::{ diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden/src/vault/cipher/cipher.rs index 9552c83c1..34f01ca60 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden/src/vault/cipher/cipher.rs @@ -46,7 +46,8 @@ pub struct Cipher { pub folder_id: Option, pub collection_ids: Vec, - /// More recent ciphers uses individual encryption keys to encrypt the other fields of the Cipher. + /// More recent ciphers uses individual encryption keys to encrypt the other fields of the + /// Cipher. pub key: Option, pub name: EncString, diff --git a/crates/bitwarden/src/vault/send.rs b/crates/bitwarden/src/vault/send.rs index b062ff9db..aba67e00c 100644 --- a/crates/bitwarden/src/vault/send.rs +++ b/crates/bitwarden/src/vault/send.rs @@ -197,8 +197,9 @@ impl KeyEncryptable for SendFileView { impl LocateKey for Send {} impl KeyDecryptable for Send { fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result { - // For sends, we first decrypt the send key with the user key, and stretch it to it's full size - // For the rest of the fields, we ignore the provided SymmetricCryptoKey and the stretched key + // For sends, we first decrypt the send key with the user key, and stretch it to it's full + // size For the rest of the fields, we ignore the provided SymmetricCryptoKey and + // the stretched key let k: Vec = self.key.decrypt_with_key(key)?; let key = Send::derive_shareable_key(&k)?; @@ -230,8 +231,9 @@ impl KeyDecryptable for Send { impl KeyDecryptable for Send { fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result { - // For sends, we first decrypt the send key with the user key, and stretch it to it's full size - // For the rest of the fields, we ignore the provided SymmetricCryptoKey and the stretched key + // For sends, we first decrypt the send key with the user key, and stretch it to it's full + // size For the rest of the fields, we ignore the provided SymmetricCryptoKey and + // the stretched key let key = Send::get_key(&self.key, key)?; Ok(SendListView { @@ -253,8 +255,9 @@ impl KeyDecryptable for Send { impl LocateKey for SendView {} impl KeyEncryptable for SendView { fn encrypt_with_key(self, key: &SymmetricCryptoKey) -> Result { - // For sends, we first decrypt the send key with the user key, and stretch it to it's full size - // For the rest of the fields, we ignore the provided SymmetricCryptoKey and the stretched key + // For sends, we first decrypt the send key with the user key, and stretch it to it's full + // size For the rest of the fields, we ignore the provided SymmetricCryptoKey and + // the stretched key let k = match (self.key, self.id) { // Existing send, decrypt key (Some(k), _) => URL_SAFE_NO_PAD diff --git a/crates/bitwarden/src/vault/totp.rs b/crates/bitwarden/src/vault/totp.rs index e99cbfabd..6ba754034 100644 --- a/crates/bitwarden/src/vault/totp.rs +++ b/crates/bitwarden/src/vault/totp.rs @@ -206,7 +206,8 @@ fn derive_binary(hash: Vec) -> u32 { | hash[offset + 3] as u32 } -/// This code is migrated from our javascript implementation and is not technically a correct base32 decoder since we filter out various characters, and use exact chunking. +/// This code is migrated from our javascript implementation and is not technically a correct base32 +/// decoder since we filter out various characters, and use exact chunking. fn decode_b32(s: &str) -> Vec { let s = s.to_uppercase(); diff --git a/crates/bws/src/render.rs b/crates/bws/src/render.rs index 83c5cd532..f9563c81b 100644 --- a/crates/bws/src/render.rs +++ b/crates/bws/src/render.rs @@ -42,7 +42,8 @@ pub(crate) fn serialize_response, const N: usiz match output { Output::JSON => { let mut text = serde_json::to_string_pretty(&data).unwrap(); - // Yaml/table/tsv serializations add a newline at the end, so we do the same here for consistency + // Yaml/table/tsv serializations add a newline at the end, so we do the same here for + // consistency text.push('\n'); pretty_print("json", &text, color); } @@ -110,7 +111,8 @@ fn pretty_print(language: &str, data: &str, color: bool) { } } -// We're using const generics for the array lengths to make sure the header count and value count match +// We're using const generics for the array lengths to make sure the header count and value count +// match pub(crate) trait TableSerialize: Sized { fn get_headers() -> [&'static str; N]; fn get_values(&self) -> Vec<[String; N]>; diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index 0cfc045a0..f9f074485 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -3,8 +3,9 @@ use std::{fs::File, io::Write}; use anyhow::Result; use schemars::{schema::RootSchema, schema_for, JsonSchema}; -/// Creates a json schema file for any type passed in using Schemars. The filename and path of the generated -/// schema file is derived from the namespace passed into the macro or supplied as the first argument. +/// Creates a json schema file for any type passed in using Schemars. The filename and path of the +/// generated schema file is derived from the namespace passed into the macro or supplied as the +/// first argument. /// /// The schema filename is given by the last namespace element and trims off any `>` characters. /// This means the filename will represent the last _generic_ type of the type given. @@ -30,7 +31,8 @@ use schemars::{schema::RootSchema, schema_for, JsonSchema}; /// ``` /// write_schema_for!(response::two_factor_login_response::two_factor_providers::TwoFactorProviders); /// ``` -/// will generate `TwoFactorProviders.json` at `{{pwd}}/response/two_factor_login_response/TwoFactorProviders.json` +/// will generate `TwoFactorProviders.json` at +/// `{{pwd}}/response/two_factor_login_response/TwoFactorProviders.json` /// /// ## Path specified /// diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..bb3baeccd --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,7 @@ +# Wrap comments and increase the width of comments to 100 +comment_width = 100 +wrap_comments = true + +# Sort and group imports +group_imports = "StdExternalCrate" +imports_granularity = "Crate"