pub struct Digest { /* private fields */ }
Expand description
Digest
struct for CRC calculation
table
: Calculation table generated from input parameters.initial
: Initial value.value
: Current value of the CRC calculation.final_xor
: Final value to XOR with when callingDigest::sum32()
.calc
: Type of calculation. See its documentation for details.
Implementations
sourceimpl Digest
impl Digest
sourcepub const fn new(poly: u32) -> Digest
pub const fn new(poly: u32) -> Digest
Creates a new Digest from input polynomial.
Example
use crc::{crc32, Hasher32};
let mut digest = crc32::Digest::new(crc32::IEEE);
digest.write(b"123456789");
assert_eq!(digest.sum32(), 0xcbf43926);;
sourcepub const fn new_with_initial(poly: u32, initial: u32) -> Digest
pub const fn new_with_initial(poly: u32, initial: u32) -> Digest
Creates a new Digest from input polynomial and initial value.
Example
use crc::{crc32, Hasher32};
let mut digest = crc32::Digest::new_with_initial(crc32::IEEE, 0u32);
digest.write(b"123456789");
assert_eq!(digest.sum32(), 0xcbf43926);
sourcepub fn new_custom(
poly: u32,
initial: u32,
final_xor: u32,
calc: CalcType
) -> Digest
pub fn new_custom(
poly: u32,
initial: u32,
final_xor: u32,
calc: CalcType
) -> Digest
Creates a fully customized Digest from input parameters.
Example
use crc::{crc32, Hasher32};
let mut digest = crc32::Digest::new_custom(crc32::IEEE, !0u32, !0u32, crc::CalcType::Reverse);
digest.write(b"123456789");
assert_eq!(digest.sum32(), 0xcbf43926);
Trait Implementations
sourceimpl Hasher for Digest
impl Hasher for Digest
1.3.0fn write_u8(&mut self, i: u8)
fn write_u8(&mut self, i: u8)
Writes a single
u8
into this hasher.1.3.0fn write_u16(&mut self, i: u16)
fn write_u16(&mut self, i: u16)
Writes a single
u16
into this hasher.1.3.0fn write_u32(&mut self, i: u32)
fn write_u32(&mut self, i: u32)
Writes a single
u32
into this hasher.1.3.0fn write_u64(&mut self, i: u64)
fn write_u64(&mut self, i: u64)
Writes a single
u64
into this hasher.1.26.0fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128
into this hasher.1.3.0fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
Writes a single
usize
into this hasher.1.3.0fn write_i8(&mut self, i: i8)
fn write_i8(&mut self, i: i8)
Writes a single
i8
into this hasher.1.3.0fn write_i16(&mut self, i: i16)
fn write_i16(&mut self, i: i16)
Writes a single
i16
into this hasher.1.3.0fn write_i32(&mut self, i: i32)
fn write_i32(&mut self, i: i32)
Writes a single
i32
into this hasher.1.3.0fn write_i64(&mut self, i: i64)
fn write_i64(&mut self, i: i64)
Writes a single
i64
into this hasher.1.26.0fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
Writes a single
i128
into this hasher.1.3.0fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize
into this hasher.fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
🔬This is a nightly-only experimental API. (
hasher_prefixfree_extras
)Writes a length prefix into this hasher, as part of being prefix-free. Read more
Auto Trait Implementations
impl RefUnwindSafe for Digest
impl Send for Digest
impl Sync for Digest
impl Unpin for Digest
impl UnwindSafe for Digest
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more