AshOnetime.Canonical (ash_onetime v0.5.0)

Copy Markdown View Source

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.

Summary

Types

result(value)

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

value()

@type value() ::
  nil
  | boolean()
  | integer()
  | binary()
  | atom()
  | [value()]
  | %{optional(value()) => value()}

Functions

encode(value)

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