Postgrex v0.11.1 Postgrex.Extension behaviour
An extension knows how to encode and decode Postgres types to and from Elixir values.
Summary
Callbacks
Should decode a binary in the specified Postgres protocol format to an Elixir value
Should encode an Elixir value to a binary in the specified Postgres protocol format
Returns the format the type should be encoded as. See http://www.postgresql.org/docs/9.4/static/protocol-overview.html#PROTOCOL-FORMAT-CODES
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
Specifies the types the extension matches, see Postgrex.TypeInfo
for
specification of the fields
Types
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) :: iodata
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.
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.