Skip to content

Commit 960465d

Browse files
author
tac0turtle
committed
fmt
1 parent d4afbdf commit 960465d

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

client/crates/types/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5757
.btree_map(".")
5858
// Generate to our output directory
5959
.out_dir(&proto_dir)
60-
.compile_protos(&proto_files, &[proto_root.clone()])?;
60+
.compile_protos(&proto_files, std::slice::from_ref(&proto_root.clone()))?;
6161

6262
println!("cargo:rerun-if-changed={}", proto_root.display());
6363
Ok(())

client/crates/types/src/compression.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ pub fn decompress_blob(compressed_blob: &[u8]) -> Result<Bytes> {
8787
// This could be either a legacy blob or a corrupted header
8888
// Use heuristics to determine which
8989

90-
let original_size =
91-
u64::from_le_bytes(compressed_blob[1..9].try_into().unwrap_or([0; 8]));
90+
let original_size = u64::from_le_bytes(compressed_blob[1..9].try_into().unwrap_or([0; 8]));
9291

9392
// If flag is in printable ASCII range (32-126) and size is unreasonable,
9493
// it's likely a legacy text blob
@@ -115,7 +114,7 @@ pub fn decompress_blob(compressed_blob: &[u8]) -> Result<Bytes> {
115114
// Decompress with ruzstd
116115
let mut decoder = StreamingDecoder::new(payload)
117116
.map_err(|e| CompressionError::DecompressionFailed(e.to_string()))?;
118-
117+
119118
let mut decompressed = Vec::new();
120119
decoder
121120
.read_to_end(&mut decompressed)
@@ -229,16 +228,16 @@ mod tests {
229228
// Create a blob with uncompressed header
230229
let original_data = b"test data";
231230
let mut blob = Vec::with_capacity(COMPRESSION_HEADER_SIZE + original_data.len());
232-
231+
233232
// Add header
234233
blob.push(FLAG_UNCOMPRESSED);
235234
blob.extend_from_slice(&(original_data.len() as u64).to_le_bytes());
236235
blob.extend_from_slice(original_data);
237-
236+
238237
// Decompress
239238
let decompressed = decompress_blob(&blob).unwrap();
240239
assert_eq!(original_data, decompressed.as_ref());
241-
240+
242241
// Check info
243242
let info = get_compression_info(&blob);
244243
assert!(!info.is_compressed);
@@ -252,11 +251,11 @@ mod tests {
252251
let mut blob = Vec::new();
253252
blob.push(FLAG_UNCOMPRESSED);
254253
blob.extend_from_slice(&100u64.to_le_bytes());
255-
blob.extend_from_slice(&vec![0u8; 100]);
254+
blob.extend_from_slice(&[0u8; 100]);
256255

257256
let info = get_compression_info(&blob);
258257
assert!(!info.is_compressed);
259258
assert_eq!(info.algorithm, "none");
260259
assert_eq!(info.original_size, 100);
261260
}
262-
}
261+
}

client/crates/types/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ pub mod v1 {
1515

1616
// Re-export compression types for convenience when compression is enabled
1717
#[cfg(feature = "compression")]
18-
pub use compression::{
19-
decompress_blob, get_compression_info, CompressionError, CompressionInfo,
20-
};
18+
pub use compression::{decompress_blob, get_compression_info, CompressionError, CompressionInfo};

client/crates/types/tests/compression_test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ fn test_uncompressed_with_header() {
3535
// Create a blob with uncompressed header
3636
let original_data = b"test data";
3737
let mut blob = Vec::with_capacity(9 + original_data.len());
38-
38+
3939
// Add header (flag + 8 bytes for size)
4040
blob.push(0x00); // FLAG_UNCOMPRESSED
4141
blob.extend_from_slice(&(original_data.len() as u64).to_le_bytes());
4242
blob.extend_from_slice(original_data);
43-
43+
4444
// Decompress
4545
let decompressed = decompress_blob(&blob).unwrap();
4646
assert_eq!(original_data, decompressed.as_ref());
@@ -64,7 +64,7 @@ fn test_compression_info() {
6464
#[test]
6565
fn test_empty_blob() {
6666
let empty = vec![];
67-
67+
6868
// Should handle empty blob gracefully
6969
let decompressed = decompress_blob(&empty).unwrap();
7070
assert_eq!(empty, decompressed.as_ref());
@@ -96,11 +96,11 @@ fn test_corrupted_blob_detection() {
9696
// Create a blob that looks like it has a header but is corrupted
9797
let mut corrupted = vec![0u8; 20];
9898
corrupted[0] = 0xAB; // Invalid flag that's not ASCII
99-
// Set a reasonable size that suggests this was meant to be compressed
99+
// Set a reasonable size that suggests this was meant to be compressed
100100
let size_bytes = 1000u64.to_le_bytes();
101101
corrupted[1..9].copy_from_slice(&size_bytes);
102102

103103
// Should detect as corrupted
104104
let result = decompress_blob(&corrupted);
105105
assert!(result.is_err());
106-
}
106+
}

0 commit comments

Comments
 (0)