logos.lang.hash

Module lang · package logos-lang

Traits

traitBuildHasher

trait BuildHasher

Factory producing fresh H hashers; lets containers keep one seed across many hashes.

Parameterised over H: Hasher in lieu of an associated type (Logos has none yet).

Implemented by: DefaultBuildHasher

traitHash

trait Hash

Types hashable through any Hasher; mirrors core::hash::Hash.

Implemented by: i32 i64 u32 u64 u8 i8 bool usize $tuple$2 $tuple$3 $tuple$4 $tuple$5 $tuple$6 $tuple$7 $tuple$8 str

traitHasher

trait Hasher

Accumulates a hash over a stream of integer writes; finish yields the result.

No byte-stream writer yet — values are fed as whole integers (see Hash for str for the byte-slice workaround).

Implemented by: FxHasher SipHasher

Types

structDefaultBuildHasher

struct DefaultBuildHasher

BuildHasher for the default hasher: a zero-keyed SipHasher.

Mirrors std::collections::hash_map::DefaultHasher (Rust uses SipHash-1-3; Logos uses SipHash-2-4 — slightly slower, equally collision-resistant).

Implements: BuildHasher

Methods

fn build_hasher(self: &DefaultBuildHasher) -> SipHasher

structFxHasher

struct FxHasher

Fast non-cryptographic Hasher using rustc’s FxHash mix; not collision-resistant against adversarial inputs.

Implements: Hasher

Fields

s: u64

Methods

fn finish(self: &FxHasher) -> u64
fn write_bool(self: &mut FxHasher, val: bool) -> void
fn write_i32(self: &mut FxHasher, val: i32) -> void
fn write_i64(self: &mut FxHasher, val: i64) -> void
fn write_u32(self: &mut FxHasher, val: u32) -> void
fn write_u64(self: &mut FxHasher, val: u64) -> void

structSipHasher

struct SipHasher

SipHash-2-4 Hasher with a 128-bit key; each write_* feeds one 64-bit block.

v0..v3 are the four SipHash internal state words.

Implements: Hasher

Fields

length: u64

Count of bytes compressed so far; each write_* accounts eight.

v0: u64
v1: u64
v2: u64
v3: u64

Methods

fn finish(self: &SipHasher) -> u64
fn write_bool(self: &mut SipHasher, val: bool) -> void
fn write_i32(self: &mut SipHasher, val: i32) -> void
fn write_i64(self: &mut SipHasher, val: i64) -> void
fn write_u32(self: &mut SipHasher, val: u32) -> void
fn write_u64(self: &mut SipHasher, val: u64) -> void

Functions

fndefault_build_hasher

fn default_build_hasher() -> DefaultBuildHasher

Creates a DefaultBuildHasher.

fnfnv1a_bytes

fn fnv1a_bytes(ptr: *const u8, len: u64) -> u64

Computes 64-bit FNV-1a over the byte range [ptr, ptr + len).

Byte-slice hash for string / byte-buffer keys — the case FxHasher’s typed writers don’t cover. Non-cryptographic; adequate for hash-map collision distribution on non-adversarial inputs. Caller must ensure ptr is valid for len bytes.

fnfx_hasher_new

fn fx_hasher_new() -> FxHasher

Creates an FxHasher with zero initial state.

fnsip_hasher_new

fn sip_hasher_new() -> SipHasher

Creates a SipHasher with the all-zero key.

fnsip_hasher_with_keys

fn sip_hasher_with_keys(k0: u64, k1: u64) -> SipHasher

Creates a SipHasher keyed with the 128-bit key (k0, k1).