From c2453046fa796ef35b70979eeac06f2a636db4cb Mon Sep 17 00:00:00 2001 From: Avinash Sajjanshetty Date: Sat, 27 Sep 2025 18:16:51 +0530 Subject: [PATCH] clippy fixes --- core/storage/encryption.rs | 9 +++---- .../query_processing/encryption.rs | 25 ++++++------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/core/storage/encryption.rs b/core/storage/encryption.rs index 125744344..4ef9e63b9 100644 --- a/core/storage/encryption.rs +++ b/core/storage/encryption.rs @@ -63,7 +63,7 @@ use turso_macros::match_ignore_ascii_case; /// ↓ /// Turso Encrypted Header: "Turso" + Version + Cipher ID + Unused /// ``` - +/// /// constants used for the Turso page header in the encrypted dbs. const TURSO_HEADER_PREFIX: &[u8] = b"Turso"; const TURSO_VERSION: u8 = 0x00; @@ -552,8 +552,7 @@ impl EncryptionContext { let version = header[5]; if version != TURSO_VERSION { return Err(LimboError::InternalError(format!( - "Unsupported Turso header version: expected {}, got {}", - TURSO_VERSION, version + "Unsupported Turso header version: expected {TURSO_VERSION}, got {version}" ))); } @@ -984,9 +983,7 @@ mod tests { page[..SQLITE_HEADER.len()].copy_from_slice(SQLITE_HEADER); let mut rng = rand::thread_rng(); // 48 is the max reserved bytes we might need for metadata with any cipher - for i in SQLITE_HEADER.len()..DEFAULT_ENCRYPTED_PAGE_SIZE - 48 { - page[i] = rng.gen(); - } + rng.fill(&mut page[SQLITE_HEADER.len()..DEFAULT_ENCRYPTED_PAGE_SIZE - 48]); page } diff --git a/tests/integration/query_processing/encryption.rs b/tests/integration/query_processing/encryption.rs index f61c6f0bd..3fc7a8e63 100644 --- a/tests/integration/query_processing/encryption.rs +++ b/tests/integration/query_processing/encryption.rs @@ -338,8 +338,7 @@ fn test_corruption_associated_data_bytes() -> anyhow::Result<()> { assert!( should_panic.is_err(), - "should panic when accessing encrypted DB with corrupted associated data at position {}", - corrupt_pos + "should panic when accessing encrypted DB with corrupted associated data at position {corrupt_pos}", ); } } @@ -364,18 +363,12 @@ fn test_turso_header_structure() -> anyhow::Result<()> { assert_eq!( &header[0..5], b"Turso", - "Magic bytes should be 'Turso' for {}", - description - ); - assert_eq!( - header[5], 0x00, - "Version should be 0x00 for {}", - description + "Magic bytes should be 'Turso' for {description}" ); + assert_eq!(header[5], 0x00, "Version should be 0x00 for {description}"); assert_eq!( header[6], expected_cipher_id, - "Cipher ID should be {} for {}", - expected_cipher_id, description + "Cipher ID should be {expected_cipher_id} for {description}" ); // the unused bytes should be zeroed @@ -445,12 +438,8 @@ fn test_turso_header_structure() -> anyhow::Result<()> { { let conn = tmp_db.connect_limbo(); - run_query(&tmp_db, &conn, &format!("PRAGMA hexkey = '{}';", hexkey))?; - run_query( - &tmp_db, - &conn, - &format!("PRAGMA cipher = '{}';", cipher_name), - )?; + run_query(&tmp_db, &conn, &format!("PRAGMA hexkey = '{hexkey}';"))?; + run_query(&tmp_db, &conn, &format!("PRAGMA cipher = '{cipher_name}';"))?; run_query( &tmp_db, &conn, @@ -459,7 +448,7 @@ fn test_turso_header_structure() -> anyhow::Result<()> { do_flush(&conn, &tmp_db)?; } - verify_header(&db_path.to_str().unwrap(), expected_id, description)?; + verify_header(db_path.to_str().unwrap(), expected_id, description)?; } Ok(()) }