Skip to content

Commit 8a494c3

Browse files
committed
Add DynDigest::box_clone() and Debug support
1 parent 4339650 commit 8a494c3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bench = true
2020

2121
[dependencies]
2222
crc = "3"
23-
digest = "0.10"
23+
digest = { version = "0.10", features = ["alloc"] }
2424
rand = "0.9"
2525
libc = "0.2.171"
2626
regex = "1.11.1"
@@ -45,6 +45,8 @@ name = "benchmark"
4545
harness = false
4646

4747
[features]
48+
alloc = []
49+
4850
# enable VPCLMULQDQ support in Rust for x86_64 using nightly toolchain builds
4951
vpclmulqdq = []
5052

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type CalculatorFn = fn(
181181
/// The `Digest` struct maintains the state of the CRC computation, including
182182
/// the current state, the amount of data processed, the CRC parameters, and
183183
/// the calculator function used to perform the CRC calculation.
184+
#[derive(Copy, Clone, Debug)]
184185
pub struct Digest {
185186
/// The current state of the CRC computation.
186187
state: u64,
@@ -243,6 +244,10 @@ impl DynDigest for Digest {
243244
fn output_size(&self) -> usize {
244245
self.params.width as usize / 8
245246
}
247+
248+
fn box_clone(&self) -> Box<dyn DynDigest> {
249+
Box::new(self.clone())
250+
}
246251
}
247252

248253
impl Digest {

src/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::arch;
66
use crate::traits::{CrcCalculator, CrcWidth};
77
use crate::CrcAlgorithm;
88

9-
#[derive(Clone, Copy)]
9+
#[derive(Clone, Copy, Debug)]
1010
pub struct CrcParams {
1111
pub algorithm: CrcAlgorithm,
1212
pub name: &'static str,

0 commit comments

Comments
 (0)