XmtpElixirSdk.CodecRegistry (xmtp_elixir_sdk v0.1.2)

Copy Markdown

Registry of custom content codecs keyed by canonical content type.

Summary

Types

codec_module()

@type codec_module() :: module()

t()

@type t() :: %XmtpElixirSdk.CodecRegistry{
  codecs: %{optional(String.t()) => codec_module()}
}

Functions

decode(registry, other)

@spec decode(t(), XmtpElixirSdk.Content.Unknown.t() | term()) ::
  {:ok, term()} | {:error, :missing_codec | XmtpElixirSdk.Error.t()}

encode(registry, codec, value)

@spec encode(t(), codec_module(), term()) ::
  {:ok, XmtpElixirSdk.Content.Unknown.t()} | {:error, XmtpElixirSdk.Error.t()}

get_codec(codec_registry, content_type)

@spec get_codec(t(), XmtpElixirSdk.Types.ContentTypeId.t() | String.t()) ::
  codec_module() | nil

new(codecs \\ [])

@spec new([codec_module()]) :: t()

register(registry, codec)

@spec register(t(), codec_module()) :: t()