Skir.RPC.TypeDescriptor (skir_elixir v1.0.0)

Copy Markdown View Source

Builds, serializes, and parses the self-describing type JSON used by Skir reflection, SkirRPC's list endpoint, and Skir Studio.

Summary

Functions

Parses a %Skir.RPC.TypeDescriptor{} from a UTF-8 JSON string.

Like from_json/1, but raises ArgumentError on failure.

Parses a %Skir.RPC.TypeDescriptor{} from a decoded JSON map.

Like from_map/1, but raises ArgumentError on failure.

Builds a %Skir.RPC.TypeDescriptor{} from a Skir.type().

Returns the 2-space pretty-printed JSON string for a Skir.type() or %Skir.RPC.TypeDescriptor{}.

Returns a JSON-compatible map representation of a Skir.type() or %Skir.RPC.TypeDescriptor{}.

Types

t()

@type t() :: %Skir.RPC.TypeDescriptor{records: [map()], type: map()}

Functions

from_json(json)

@spec from_json(binary()) :: {:ok, t()} | {:error, String.t()}

Parses a %Skir.RPC.TypeDescriptor{} from a UTF-8 JSON string.

from_json!(json)

@spec from_json!(binary()) :: t()

Like from_json/1, but raises ArgumentError on failure.

from_map(arg1)

@spec from_map(map()) :: {:ok, t()} | {:error, String.t()}

Parses a %Skir.RPC.TypeDescriptor{} from a decoded JSON map.

from_map!(map)

@spec from_map!(map()) :: t()

Like from_map/1, but raises ArgumentError on failure.

from_type(type)

@spec from_type(Skir.type()) :: t()

Builds a %Skir.RPC.TypeDescriptor{} from a Skir.type().

to_json(td)

@spec to_json(Skir.type() | t()) :: binary()

Returns the 2-space pretty-printed JSON string for a Skir.type() or %Skir.RPC.TypeDescriptor{}.

to_map(td)

@spec to_map(Skir.type() | t()) :: map()

Returns a JSON-compatible map representation of a Skir.type() or %Skir.RPC.TypeDescriptor{}.