Musubi.Input (musubi v0.3.0)

Copy Markdown View Source

Compile-time DSL entrypoint for Musubi input-object schemas.

Input modules are pure data types used as command-payload field shapes. They are distinct from Musubi.State (render output) and Musubi.Store (mountable runtime nodes): no mount/1, no render/1, no commands, no streams, no child eligibility. Only typed fields and validation.

Inputs participate in:

  • Musubi.Wire — auto-derived so input structs serialize like state.
  • Musubi.Type.valid?/3Module.t() references to an input module recurse via __musubi_validate_input__/1.
  • Musubi.Hooks.ValidateCommandSchema — payload fields typed MyInput.t() validate by recursing into the input module.

Examples

defmodule UserInput do
  use Musubi.Input

  input do
    field :name, String.t()
    field :age, integer()
  end
end

Summary

Functions

Sets up a module to declare a reusable Musubi input with input do ... end.

Returns whether module is a Musubi input-object module.

Functions

__using__(opts)

(macro)
@spec __using__(keyword()) :: Macro.t()

Sets up a module to declare a reusable Musubi input with input do ... end.

Examples

defmodule UserInput do
  use Musubi.Input

  input do
    field :name, String.t()
  end
end

input_module?(module)

@spec input_module?(module()) :: boolean()

Returns whether module is a Musubi input-object module.

Examples

iex> defmodule InputKindExample do
...>   use Musubi.Input
...>   input do
...>     field :name, String.t()
...>   end
...> end
iex> Musubi.Input.input_module?(InputKindExample)
true
iex> Musubi.Input.input_module?(Musubi.Socket)
false