API
#hash/crc32
Xu 0.8.8 API
import: #hash/crc32
counts: 7 fns, 4 methods, 2 types, 3 consts, 0 ifaces
IEEE/Castagnoli/Koopman CRC-32.
const ieee
pub const ieee = 3988292384
Purpose
CRC-32 aligned with `hash/crc32` (ieee / castagnoli / koopman). Pure i64 arithmetic with 32-bit masks — no mutable globals (each make_table) returns an owning 256-entry table). checksum_ieee uses a precomputed ieee table so small checksums do not rebuild 256 entries from the poly. Value `3988292384`.
Parameters
none
const castagnoli
pub const castagnoli = 2197175160
Purpose
Public constant `castagnoli`. Value `2197175160`.
Parameters
none
const koopman
pub const koopman = 3945912366
Purpose
Public constant `koopman`. Value `3945912366`.
Parameters
none
struct Table
pub struct Table {
pub entries []int
}
Purpose
Public struct `Table`.
Parameters
entries []int- field ([]int)
make_table
pub fn make_table(poly int) Table
Purpose
Make table.
Parameters
poly int- poly (int)
Returns
Table — a value of this type
update
pub fn update(tab &Table, crc int, data &string) int
Purpose
update; returns int.
Parameters
tab &Table- tab (borrowed; caller keeps it; type &Table)
crc int- crc (int)
data &string- data (borrowed; caller keeps it; type &string)
Returns
int — a value of this type
checksum
pub fn checksum(data &string, tab &Table) int
Purpose
checksum; returns int.
Parameters
data &string- data (borrowed; caller keeps it; type &string)
tab &Table- tab (borrowed; caller keeps it; type &Table)
Returns
int — a value of this type
struct Digest
pub struct Digest {
pub tab Table
pub crc int
pub is_ieee bool
}
Purpose
Public struct `Digest`.
Parameters
tab Table- field (Table)
crc int- field (int)
is_ieee bool- field (bool)
new_ieee
Purpose
Construct ieee.
Parameters
none
Returns
Digest — a value of this type
(&mut Digest) write
pub fn (d &mut Digest) write(p &string) int
Purpose
Method on `&mut Digest`: write data and return the byte count.
Parameters
d &mut Digest- receiver &mut Digest (exclusive borrow)
p &string- p (borrowed; caller keeps it; type &string)
Returns
int — bytes written
(&Digest) sum
pub fn (d &Digest) sum() int
Purpose
Method on `&Digest`: compute a digest (often lowercase hex).
Parameters
d &Digest- receiver &Digest (borrow)
Returns
int — a value of this type
(&Digest) size
pub fn (d &Digest) size() int
Purpose
Method on `&Digest`: return the size.
Parameters
d &Digest- receiver &Digest (borrow)
Returns
int — a value of this type
(&mut Digest) reset
pub fn (d &mut Digest) reset()
Purpose
Method on `&mut Digest`: clear internal state so the value can be reused.
Parameters
d &mut Digest- receiver &mut Digest (exclusive borrow)
checksum_ieee
pub fn checksum_ieee(data &string) int
Purpose
Checksum ieee.
Parameters
data &string- data (borrowed; caller keeps it; type &string)
Returns
int — a value of this type
checksum_castagnoli
pub fn checksum_castagnoli(data &string) int
Purpose
Checksum castagnoli.
Parameters
data &string- data (borrowed; caller keeps it; type &string)
Returns
int — a value of this type
checksum_koopman
pub fn checksum_koopman(data &string) int
Purpose
Checksum koopman.
Parameters
data &string- data (borrowed; caller keeps it; type &string)
Returns
int — a value of this type