| 1 | //! Hash functions and hash utilities |
| 2 | |
| 3 | /// Compute a CRC32 hash from the given `bytes`, returning the CRC32 hash. |
| 4 | /// |
| 5 | /// When calling this function for the first time, `previous_value` should be `0`. |
| 6 | /// Otherwise, it should be the previous return value of this function to provide a hash |
| 7 | /// of multiple sequential chunks of `bytes`. |
| 8 | #[cfg(feature = "crc32")] |
| 9 | pub fn crc32_updaterust-analyzer cargo gix-features 0.48.0 hash/crc32_update().(previous_value: u32, bytes: &[u8]) -> u32 { |
| 10 | let mut h = crc32fastrust-analyzer cargo crc32fast 1.5.0 crate/::Hasherrust-analyzer cargo crc32fast 1.5.0 Hasher#::new_with_initialrust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]new_with_initial().(previous_value); |
| 11 | h.updaterust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]update().(bytes); |
| 12 | h.finalizerust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]finalize().() |
| 13 | } |
| 14 | |
| 15 | /// Compute a CRC32 value of the given input `bytes`. |
| 16 | /// |
| 17 | /// In case multiple chunks of `bytes` are present, one should use [`crc32_update()`] instead. |
| 18 | #[cfg(feature = "crc32")] |
| 19 | pub fn crc32rust-analyzer cargo gix-features 0.48.0 hash/crc32().(bytes: &[u8]) -> u32 { |
| 20 | let mut h = crc32fastrust-analyzer cargo crc32fast 1.5.0 crate/::Hasherrust-analyzer cargo crc32fast 1.5.0 Hasher#::newrust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]new().(); |
| 21 | h.updaterust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]update().(bytes); |
| 22 | h.finalizerust-analyzer cargo crc32fast 1.5.0 impl#[Hasher]finalize().() |
| 23 | } |