XU XUv0.8.8
中文

API

#hash/crc64

import: #hash/crc64

counts: 7 fns, 4 methods, 2 types, 2 consts, 0 ifaces

ISO/ECMA CRC-64.

const iso

XuAPI
pub const iso = -2882303761517117440

Purpose

CRC-64 aligned with `hash/crc64` (iso / ecma). Pure i64 arithmetic carrying u64 lanes: arithmetic right shift is masked to logical (`>> 1` with 2^63-1, `>> 8` with 2^56-1). No mutable globals — each make_table owns a 256-entry table. Polynomials that set bit 63 are stored as two's-complement negatives (hex 0x8… literals have historically been lexer-hostile). Value `-2882303761517117440`.

Parameters

none

const ecma

XuAPI
pub const ecma = -3932672073523589310

Purpose

Public constant `ecma`. Value `-3932672073523589310`.

Parameters

none

struct Table

XuAPI
pub struct Table {
    pub entries []int
}

Purpose

Public struct `Table`.

Parameters

entries []int
field ([]int)

make_table

XuAPI
pub fn make_table(poly int) Table

Purpose

Make table.

Parameters

poly int
poly (int)

Returns

Table — a value of this type

update

XuAPI
pub fn update(crc int, tab &Table, data &string) int

Purpose

update; returns int.

Parameters

crc int
crc (int)
tab &Table
tab (borrowed; caller keeps it; type &Table)
data &string
data (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

checksum

XuAPI
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

XuAPI
pub struct Digest {
    pub tab Table
    pub crc int
}

Purpose

Public struct `Digest`.

Parameters

tab Table
field (Table)
crc int
field (int)

new_iso

XuAPI
pub fn new_iso() Digest

Purpose

Construct iso.

Parameters

none

Returns

Digest — a value of this type

new_ecma

XuAPI
pub fn new_ecma() Digest

Purpose

Construct ecma.

Parameters

none

Returns

Digest — a value of this type

(&mut Digest) write

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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_iso

XuAPI
pub fn checksum_iso(data &string) int

Purpose

Checksum iso.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

checksum_ecma

XuAPI
pub fn checksum_ecma(data &string) int

Purpose

Checksum ecma.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

int — a value of this type