moonbitstack/moonstl/spec does not have a README file

    Refused

    pub(all) suberror Refused {
    Capacity(got~ : Int)
    Probability(got~ : Double)
    Arity(got~ : Int)
    Precision(got~ : Int)
    DuplicateValue
    NonMonotone(got~ : UInt64, limit~ : UInt64)
    TooMany(limit~ : Int)
    Incompatible
    Overlap
    } derive(Eq,
    Debug
    )

    The only error this module raises. Input that cannot be used — a capacity that cannot hold the data, a rate outside its range, an arity that is not a tree — is refused here; a lookup that simply finds nothing returns None instead, and an out-of-range index aborts as Array does.
    impl Show for Refused

    Refused::equal

    fn Refused::equal(Refused, Refused) -> Bool

    Refused::not_equal

    fn Refused::not_equal(x : Refused, y : Refused) -> Bool

    Refused::output

    fn Refused::output(self : Refused, logger : &Logger) -> Unit

    Refused::to_repr

    Refused::to_string

    fn Refused::to_string(self : Refused) -> String

    hash_seed

    fn hash_seed() -> Int

    The process-wide seed every hashed container starts from, drawn once from the platform's entropy on first use. A program that builds no hash table draws nothing.

    A per-process seed makes the bucket layout, and with it the iteration order, differ between runs, so a key set chosen to collide in one run does not collide in the next. Pass hash_seed=0, or any fixed value, when a run has to be reproducible.

    test {
    let a = @spec.hash_seed()
    let b = @spec.hash_seed()
    @test.assert_eq(a, b)
    }

    hash_seed_from

    fn hash_seed_from(bytes : BytesView) -> Int

    A seed derived from bytes the caller already holds, which is how a service reproduces the layout of its tables across restarts: pass the same bytes and every container lays out the same way.

    test {
    @test.assert_eq(
    @spec.hash_seed_from(b"moonstl"),
    @spec.hash_seed_from(b"moonstl"),
    )
    @test.assert_not_eq(
    @spec.hash_seed_from(b"moonstl"),
    @spec.hash_seed_from(b"moonst"),
    )
    }

    hash_seed_is_random

    fn hash_seed_is_random() -> Bool

    Whether this platform gave real entropy to hash_seed. false means the platform has no source — a wasm host without WASI — and every hashed container runs from a seed of zero, which is still correct, only predictable.

    test {
    let _ = @spec.hash_seed()
    let random = @spec.hash_seed_is_random()
    @test.assert_eq(random, @spec.hash_seed_is_random())
    }