1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2025-01-22 07:09:00 +01:00

refactor: replace static with const for global constants (#5260)

Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
Dieser Commit ist enthalten in:
Integral 2025-01-11 04:06:38 +08:00 committet von GitHub
Ursprung ca7483df85
Commit 327d369188
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@ use std::num::NonZeroU32;
use data_encoding::{Encoding, HEXLOWER}; use data_encoding::{Encoding, HEXLOWER};
use ring::{digest, hmac, pbkdf2}; use ring::{digest, hmac, pbkdf2};
static DIGEST_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256; const DIGEST_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256;
const OUTPUT_LEN: usize = digest::SHA256_OUTPUT_LEN; const OUTPUT_LEN: usize = digest::SHA256_OUTPUT_LEN;
pub fn hash_password(secret: &[u8], salt: &[u8], iterations: u32) -> Vec<u8> { pub fn hash_password(secret: &[u8], salt: &[u8], iterations: u32) -> Vec<u8> {

Datei anzeigen

@ -87,7 +87,7 @@ impl MembershipType {
impl Ord for MembershipType { impl Ord for MembershipType {
fn cmp(&self, other: &MembershipType) -> Ordering { fn cmp(&self, other: &MembershipType) -> Ordering {
// For easy comparison, map each variant to an access level (where 0 is lowest). // For easy comparison, map each variant to an access level (where 0 is lowest).
static ACCESS_LEVEL: [i32; 4] = [ const ACCESS_LEVEL: [i32; 4] = [
3, // Owner 3, // Owner
2, // Admin 2, // Admin
0, // User 0, // User
@ -216,7 +216,7 @@ impl Organization {
// The number 128 should be fine, it is well within the range of an i32 // The number 128 should be fine, it is well within the range of an i32
// The same goes for the database where we only use INTEGER (the same as an i32) // The same goes for the database where we only use INTEGER (the same as an i32)
// It should also provide enough room for 100+ types, which i doubt will ever happen. // It should also provide enough room for 100+ types, which i doubt will ever happen.
static ACTIVATE_REVOKE_DIFF: i32 = 128; const ACTIVATE_REVOKE_DIFF: i32 = 128;
impl Membership { impl Membership {
pub fn new(user_uuid: UserId, org_uuid: OrganizationId) -> Self { pub fn new(user_uuid: UserId, org_uuid: OrganizationId) -> Self {