Bolty.PackStream.Packer protocol (Bolty v0.0.12)

Copy Markdown

The Bolty.PackStream.Packer protocol is responsible for serializing any Elixir data structure according to the PackStream specification.

Every concrete implementation receives the resolved %Bolty.Policy{} for the current connection as a second argument. Types whose wire format is version-dependent (currently DateTime and DateTimeWithTZOffset) pattern- match on it; the rest ignore it.

Serializing for structs

By default, all structures are serialized with all their fields. However, if it is necessary that only certain fields be considered for serialization, it is necessary to perform a derivation. Below is an example:

defmodule Book do
  @derive [{Bolty.PackStream.Packer, fields: [:name]}]
  defstruct [:name, :other_data]
end`

Summary

Types

t()

All the types that implement this protocol.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

pack(term, policy)