Struct rolling_dual_crc::Zeros[][src]

pub struct Zeros { /* fields omitted */ }
Expand description

Efficient representation of a 0u8 sequence for DualCrc::update_with_zeros.

Examples

Compute checksum of "Hello, World!" padded to 4 kiB by 0u8:

use rolling_dual_crc::{DualCrc, Zeros};

let data = "Hello, world!";
let padding_size = 4096 - data.as_bytes().len();

let mut crc = DualCrc::new();
crc.update(data);
// This is equivalent to `crc.update(&vec![0u8; padding_size])`
// but more efficient with long sequences.
crc.update_with_zeros(&Zeros::new(padding_size));
assert_eq!(crc.get32(), 0xCED9AB00);

Benchmarks

  • These benchmarks are from cargo bench zeros with 3.4 GHz i5-3570K (Ivy Bridge, 3rd gen.).
  • See crate index for main benchmarks.

In these benchmarks update and update_with_zeros use sequence lengths 64/256/1024 while Zeros::new uses sequence lengths 63/64/255/256/1023/1024 because its speed depends on the number of 1-bits in the sequence length. Low end (best) timings are with 2^n while high end (worst) timings are with 2^n-1.

Methodns / ~64 Bns / ~256 Bns / ~1024 Bcomplexity
DualCrc::update652601000Θ(n)
DualCrc::update_with_zeros909090Θ(1)
Zeros::new3 - 4303 - 6003 - 770Θ(one_bits n)

Implementations

Creates a new Zeros which represents a sequence of byte_count 0u8:s.

Complexity: Θ(one_bits n) time, Θ(1) space

See Zeros for example.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.