Macaw.Component.State (macaw_component v0.1.2)

Copy Markdown View Source

The state vocabulary a component and every host agree on (spec/01 §1.5): the standard state sources a component may write, and the value and domain types.

iex> Macaw.Component.State.conforms?(:window, %{last: 3600})
true
iex> Macaw.Component.State.conforms?(:identity, %{"host" => "a", "port" => 80})
true

Summary

Functions

Whether a value is of a type. :identity is a scalar or a non-empty map of field to scalar; :window is nil, %{last: seconds} or %{from: a, to: b}, either with an optional as_of instant; :box is %{west, south, east, north} in degrees; :camera a map and :breakpoints a list; the data-model types are Macaw.Data.Parameter's.

The domain types a local key may carry: the first eight of types/0.

The standard state sources, each with the value types it takes.

The value and domain types, in order.

Types

type()

@type type() ::
  :time
  | :number
  | :category
  | :text
  | :point
  | :identity
  | :window
  | :box
  | :camera
  | :breakpoints

Functions

conforms?(type, value)

@spec conforms?(type(), term()) :: boolean()

Whether a value is of a type. :identity is a scalar or a non-empty map of field to scalar; :window is nil, %{last: seconds} or %{from: a, to: b}, either with an optional as_of instant; :box is %{west, south, east, north} in degrees; :camera a map and :breakpoints a list; the data-model types are Macaw.Data.Parameter's.

local_types()

@spec local_types() :: [type(), ...]

The domain types a local key may carry: the first eight of types/0.

standard()

@spec standard() :: %{required(String.t()) => [type(), ...]}

The standard state sources, each with the value types it takes.

types()

@spec types() :: [type(), ...]

The value and domain types, in order.