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

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

opts :: term
t :: module

Callbacks

decode(arg0, binary, arg2, opts)

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.

encode(arg0, term, arg2, opts)

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.

format(opts)

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.

init(arg0, term)

Specs

init(Map.t, term) :: opts

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.

matching(opts)

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.