Postgrex.Extension behaviour
An extension knows how to encode and decode Postgres types to and from Elixir values.
Types ↑
t :: module
opts :: term
Callbacks
Specs:
- decode(Postgrex.TypeInfo.t, binary, Postgrex.Types.types, opts) :: term
Should decode a binary in the specified Postgres protocol format to an Elixir value.
Specs:
- encode(Postgrex.TypeInfo.t, term, Postgrex.Types.types, opts) :: binary
Should encode an Elixir value to a binary in the specified Postgres protocol format.
Specs:
- format(opts) :: :binary | :text
Returns the format the type should be encoded as. See http://www.postgresql.org/docs/9.4/static/protocol-overview.html#PROTOCOL-FORMAT-CODES.
Specs:
Should perform any initialization of the extension. The function receives the server parameters (http://www.postgresql.org/docs/9.4/static/runtime-config.html) and user options. The options returned from this function will be passed to all other callbacks.
Specs:
- matching(opts) :: [type: String.t, send: String.t, receive: String.t, input: String.t, output: String.t]
Specifies the types the extension matches, see Postgrex.TypeInfo
for
specification of the fields.