Monty.Frameworks.Actions.ActionJSONDecoder (ExTbpMonty.Core v0.1.0)

Copy Markdown View Source

The action a map names.

Mirrors tbp/monty/frameworks/actions/actions.py::ActionJSONDecoder, which reads a map whose "action" key names the action and whose other keys are that action's parameters.

Monty raises ValueError for a map with no name, an unknown name, or a parameter missing. This answers {:error, reason} instead: such a map arrives from outside the beam, and a run should be able to say what was wrong with it rather than end.

Quaternions are answered as {w, x, y, z} tuples, which is how the structs hold them; JSON has no tuples, so Monty converts on the way in as well.

Summary

Functions

The action object describes, or what is wrong with the object.

Functions

decode(object)

@spec decode(map()) :: {:ok, Monty.Frameworks.Actions.Action.t()} | {:error, term()}

The action object describes, or what is wrong with the object.

{:error, :missing_action} for a map with no "action" key, {:error, {:unknown_action, name}} for one naming an action this port does not have, and {:error, {:missing_parameter, name}} for one that leaves a parameter out.