# `AshOnetime.Canonical`
[🔗](https://github.com/baselabs/ash_onetime/blob/v1.5.0/lib/ash_onetime/canonical.ex#L1)

Bounded, deterministic encoding for an explicit closed value algebra.

Accepted values are `nil`, booleans, bounded integers, bounded binaries,
atoms, proper lists, and non-struct maps recursively containing only those
values. Floats, tuples, structs, improper lists, PIDs, ports, references, and
functions are deliberately outside the algebra and return a typed error.

Every value has a pinned domain tag and a 32-bit byte length. Containers also
carry a 32-bit item count. Map entries are ordered by the complete encoded key
bytes, making construction order irrelevant.

# `result`

```elixir
@type result(value) :: {:ok, value} | {:error, AshOnetime.Error.t()}
```

# `value`

```elixir
@type value() ::
  nil
  | boolean()
  | integer()
  | binary()
  | atom()
  | [value()]
  | %{optional(value()) =&gt; value()}
```

# `encode`

```elixir
@spec encode(term()) :: result(binary())
```

---

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