Struct adler::Adler32 [−][src]
Adler-32 checksum calculator.
An instance of this type is equivalent to an Adler-32 checksum: It can be created in the default
state via new
(or the provided Default
impl), or from a precalculated checksum via
from_checksum
, and the currently stored checksum can be fetched via checksum
.
This type also implements Hasher
, which makes it easy to calculate Adler-32 checksums of any
type that implements or derives Hash
. This also allows using Adler-32 in a HashMap
, although
that is not recommended (while every checksum is a hash, they are not necessarily good at being
one).
Implementations
impl Adler32
[src]
pub fn new() -> Self
[src]
Creates a new Adler-32 instance with default state.
pub fn from_checksum(sum: u32) -> Self
[src]
Creates an Adler32
instance from a precomputed Adler-32 checksum.
This allows resuming checksum calculation without having to keep the Adler32
instance
around.
Example
let parts = [ "rust", "acean", ]; let whole = adler::adler32_slice(b"rustacean"); let mut sum = Adler32::new(); sum.write_slice(parts[0].as_bytes()); let partial = sum.checksum(); // ...later let mut sum = Adler32::from_checksum(partial); sum.write_slice(parts[1].as_bytes()); assert_eq!(sum.checksum(), whole);
pub fn checksum(&self) -> u32
[src]
Returns the calculated checksum at this point in time.
pub fn write_slice(&mut self, bytes: &[u8])
[src]
Adds bytes
to the checksum calculation.
If efficiency matters, this should be called with Byte slices that contain at least a few thousand Bytes.
Trait Implementations
impl Clone for Adler32
[src]
fn clone(&self) -> Adler32
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Adler32
[src]
impl Debug for Adler32
[src]
impl Default for Adler32
[src]
impl Hasher for Adler32
[src]
fn finish(&self) -> u64
[src]
fn write(&mut self, bytes: &[u8])
[src]
pub fn write_u8(&mut self, i: u8)
1.3.0[src]
pub fn write_u16(&mut self, i: u16)
1.3.0[src]
pub fn write_u32(&mut self, i: u32)
1.3.0[src]
pub fn write_u64(&mut self, i: u64)
1.3.0[src]
pub fn write_u128(&mut self, i: u128)
1.26.0[src]
pub fn write_usize(&mut self, i: usize)
1.3.0[src]
pub fn write_i8(&mut self, i: i8)
1.3.0[src]
pub fn write_i16(&mut self, i: i16)
1.3.0[src]
pub fn write_i32(&mut self, i: i32)
1.3.0[src]
pub fn write_i64(&mut self, i: i64)
1.3.0[src]
pub fn write_i128(&mut self, i: i128)
1.26.0[src]
pub fn write_isize(&mut self, i: isize)
1.3.0[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,