Skip to content

Commit 3dd32a3

Browse files
committed
Create cache module with core data structures
- [x] 1. Create cache module with core data structures - Create `src/cache.rs` module file - Define `CrcParamsCacheKey` struct with `width`, `poly`, and `reflected` fields - Implement `Debug`, `Clone`, `PartialEq`, `Eq`, and `Hash` traits for the cache key - Add module declaration to `src/lib.rs`
1 parent 65708b4 commit 3dd32a3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.kiro/specs/crc-params-caching/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Implementation Plan
22

3-
- [ ] 1. Create cache module with core data structures
3+
- [x] 1. Create cache module with core data structures
44
- Create `src/cache.rs` module file
55
- Define `CrcParamsCacheKey` struct with `width`, `poly`, and `reflected` fields
66
- Implement `Debug`, `Clone`, `PartialEq`, `Eq`, and `Hash` traits for the cache key

src/cache.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// Cache key for storing CRC parameters that affect key generation
2+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3+
pub(crate) struct CrcParamsCacheKey {
4+
/// CRC width (32 or 64 bits)
5+
pub width: u8,
6+
/// Polynomial value used for CRC calculation
7+
pub poly: u64,
8+
/// Whether the CRC uses reflected input/output
9+
pub reflected: bool,
10+
}
11+
12+
impl CrcParamsCacheKey {
13+
pub fn new(width: u8, poly: u64, reflected: bool) -> Self {
14+
Self {
15+
width,
16+
poly,
17+
reflected,
18+
}
19+
}
20+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ use std::io::{Read, Write};
124124

125125
mod algorithm;
126126
mod arch;
127+
mod cache;
127128
mod combine;
128129
mod consts;
129130
mod crc32;

0 commit comments

Comments
 (0)