Raxol.Protocols.CoreProtocols.Serializable protocol (Raxol v2.0.1)

View Source

Protocol for serializing and deserializing data structures. Handles conversion to/from various formats (JSON, TOML, binary).

Summary

Types

t()

All the types that implement this protocol.

Functions

Deserializes data from the specified format.

Gets the serialization schema for validation.

Serializes the data to the specified format.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

deserialize(data, format, target_type)

@spec deserialize(
  binary(),
  :json | :toml | :binary | :erlang_term,
  module()
) :: {:ok, t()} | {:error, any()}

Deserializes data from the specified format.

get_schema(data)

@spec get_schema(t()) :: map()

Gets the serialization schema for validation.

serialize(data, format \\ :json)

@spec serialize(t(), :json | :toml | :binary | :erlang_term) ::
  {:ok, binary()} | {:error, any()}

Serializes the data to the specified format.