Adler32 structv0.1.0

Source
The Adler-32 of a message, computed a batch of bytes at a time.
pub struct Adler32 {
    // private fields
}

Copy, holding only the two sums, so passing one by value takes a snapshot of the checksum so far.

Constructors

Adler32

pub func Adler32() -> Adler32

Constructs a checksum with nothing written into it yet.

Returns: a hasher with nothing written to it yet

Source

Methods

Reset

pub func Reset(self: &var Adler32)

Puts the checksum back to where Adler32() leaves one. Everything written so far is forgotten.

Source

Value

pub func Value(self: &Adler32) -> uint32

The checksum of everything written so far: the second sum in the high half and the first in the low half. Writing more continues from here rather than starting over.

Returns: the checksum

Source

Implements Hasher

Adler32 conforms to Hasher.

Write

pub func Write(
    self: &var Adler32,
    bytes: *byte,
    length: uint
)

Adds length bytes at bytes to the checksum. A zero length changes nothing and is the one case in which bytes may be null. Splitting a message across several writes gives the same answer as one write. Runs in time proportional to length and allocates nothing.

NameTypeDescription
bytes*bytethe bytes to absorb
lengthuinthow many bytes; zero absorbs nothing

Source

Finish

pub func Finish(self: &var Adler32) -> uint64

The checksum of everything written so far, widened to 64 bits; the upper half is always zero.

Returns: the checksum

Source