clippy fixes

This commit is contained in:
Avinash Sajjanshetty
2025-09-27 18:16:51 +05:30
parent a2df313ad5
commit c2453046fa
2 changed files with 10 additions and 24 deletions

View File

@@ -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
}

View File

@@ -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(())
}