PhoenixMicro.Serializer behaviour (PhoenixMicro v1.0.0)

Copy Markdown View Source

Behaviour for pluggable message serialization.

The serializer is responsible for encoding PhoenixMicro.Message payloads to binary when publishing, and decoding binary back to terms when consuming.

Summary

Types

decoded()

@type decoded() :: term()

encoded()

@type encoded() :: binary()

Callbacks

content_type()

@callback content_type() :: String.t()

decode!(encoded)

@callback decode!(encoded()) :: decoded()

encode!(term)

@callback encode!(term()) :: encoded()