# `F3.Checksum`

XXH64 checksums for chunk bytes.

The pinned writer uses `xxhash_rust` `Xxh64` with seed 0. Postscript
checksums stay recorded and are not recomputed. A chunk checksum is
checked only when the footer field is present.

# `verify`

```elixir
@spec verify(binary(), non_neg_integer() | nil) :: :ok | {:error, F3.Error.t()}
```

Checks a chunk checksum. `nil` means the footer did not store one and
returns `:ok`. A mismatch is `{:error, %F3.Error{category: :checksum}}`.
This does not raise.

## Examples

    iex> :ok = F3.Checksum.verify("a", nil)
    iex> :ok = F3.Checksum.verify("a", F3.Checksum.xxh64("a"))
    iex> {:error, error} = F3.Checksum.verify("a", 1)
    iex> error.message
    "chunk checksum mismatch"

# `xxh64`

```elixir
@spec xxh64(binary()) :: non_neg_integer()
```

XXH64 of `bytes` with seed 0. `bytes` must be a binary. Any other term
raises `FunctionClauseError`.

## Examples

    iex> F3.Checksum.xxh64("")
    17241709254077376921

    iex> F3.Checksum.xxh64("a")
    15154266338359012955

# `xxh64`

```elixir
@spec xxh64(binary(), integer()) :: non_neg_integer()
```

XXH64 of `bytes` with an integer seed. Seed 0 matches `xxh64/1`.

## Examples

    iex> F3.Checksum.xxh64("a", 0)
    15154266338359012955

---

*Consult [api-reference.md](api-reference.md) for complete listing*
