Skip to main content

Checksum

Trait Checksum 

Source
pub trait Checksum {
    type Output: ChecksumOutput;

    // Required methods
    fn new() -> Self;
    fn update(&mut self, data: &[u8]);
    fn sum(self) -> Self::Output;

    // Provided method
    fn checksum(data: &[u8]) -> Self::Output
       where Self: Sized { ... }
}
Expand description

A trait for computing checksums.

Types implementing this trait can compute a hash incrementally via update and sum, or in a single call via checksum.

Required Associated Types§

Source

type Output: ChecksumOutput

The type of the resulting checksum value.

Required Methods§

Source

fn new() -> Self

Create a new checksum instance with default settings (seed = 0, default secret for XXH3 variants).

Source

fn update(&mut self, data: &[u8])

Feed additional data into the checksum.

Source

fn sum(self) -> Self::Output

Finalize and return the computed checksum value.

Provided Methods§

Source

fn checksum(data: &[u8]) -> Self::Output
where Self: Sized,

Compute the checksum of data in a single call.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§