Shared encoding/decoding helpers used across transports and the producer.
Provides a unified entry point for payload serialization so all transports produce and consume messages in the same format regardless of the underlying broker's wire format.
Summary
Functions
Returns the MIME content-type for the configured serializer.
Safely decodes a binary — returns {:ok, term} or {:error, reason}.
Decodes binary using the configured serializer.
Returns the decoded term.
Safely encodes a term — returns {:ok, binary} or {:error, reason}.
Encodes payload using the configured serializer.
Returns a binary.
Functions
@spec content_type() :: String.t()
Returns the MIME content-type for the configured serializer.
@spec decode(binary()) :: {:ok, term()} | {:error, Exception.t()}
Safely decodes a binary — returns {:ok, term} or {:error, reason}.
Decodes binary using the configured serializer.
Returns the decoded term.
@spec encode(term()) :: {:ok, binary()} | {:error, Exception.t()}
Safely encodes a term — returns {:ok, binary} or {:error, reason}.
Encodes payload using the configured serializer.
Returns a binary.