Trait aws_smithy_checksums::Checksum

source ·
pub trait Checksum: Send + Sync {
    // Required methods
    fn update(&mut self, bytes: &[u8]);
    fn finalize(self: Box<Self>) -> Bytes;
    fn size(&self) -> u64;
}
Expand description

Types implementing this trait can calculate checksums.

Checksum algorithms are used to validate the integrity of data. Structs that implement this trait can be used as checksum calculators. This trait requires Send + Sync because these checksums are often used in a threaded context.

Required Methods§

source

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

Given a slice of bytes, update this checksum’s internal state.

source

fn finalize(self: Box<Self>) -> Bytes

“Finalize” this checksum, returning the calculated value as Bytes or an error that occurred during checksum calculation.

HINT: To print this value in a human-readable hexadecimal format, you can use Rust’s builtin formatter.

source

fn size(&self) -> u64

Return the size of this checksum algorithms resulting checksum, in bytes.

For example, the CRC32 checksum algorithm calculates a 32 bit checksum, so a CRC32 checksum struct implementing this trait method would return 4.

Implementors§