Dextrin.Keyword (Dextrin v0.3.3)

Copy Markdown View Source

DXN keyword (:name in value position). Wraps a plain String.t(), never an Elixir atom, for the same reason as Dextrin.Symbol: atoms are never garbage collected on the BEAM, and decoding untrusted, attacker-controlled data must never be able to exhaust the atom table.

Summary

Functions

The keyword name as a trusted decode reads it: its atom, but a Dextrin.Keyword still for a name whose atom is already a value -- :nan, :positive_infinity, :negative_infinity, :nil, :true, :false -- so the keyword stays a keyword (Jan, 2026-10-20).

Types

t()

@type t() :: %Dextrin.Keyword{name: String.t()}

Functions

new(name)

@spec new(String.t()) :: t()

trusted(name)

@spec trusted(String.t()) :: atom() | t()

The keyword name as a trusted decode reads it: its atom, but a Dextrin.Keyword still for a name whose atom is already a value -- :nan, :positive_infinity, :negative_infinity, :nil, :true, :false -- so the keyword stays a keyword (Jan, 2026-10-20).

iex> Dextrin.Keyword.trusted("ok")
:ok
iex> Dextrin.Keyword.trusted("nan")
%Dextrin.Keyword{name: "nan"}