Spectre.Definition.Component (Spectre v0.3.0)

Copy Markdown View Source

One typed component in a canonical Definition envelope.

criticality tells older runtimes whether unknown semantics must fail closed. Security- and execution-relevant components use :must_understand; descriptive metadata never grants authority.

Summary

Functions

Restores a component from its portable envelope representation.

Builds and validates a canonical Definition component.

Builds a component or raises with its stable validation reason.

Returns the portable envelope representation of a component.

Types

criticality()

@type criticality() :: :must_understand | :advisory | :descriptive

t()

@type t() :: %Spectre.Definition.Component{
  component_type: atom() | String.t(),
  criticality: criticality(),
  payload: term(),
  schema_ref: String.t()
}

Functions

from_data(data)

@spec from_data(map()) :: {:ok, t()} | {:error, term()}

Restores a component from its portable envelope representation.

new(component)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, term()}

Builds and validates a canonical Definition component.

new!(attrs)

@spec new!(map() | keyword()) :: t()

Builds a component or raises with its stable validation reason.

to_data(component)

@spec to_data(t()) :: map()

Returns the portable envelope representation of a component.