Browse Source

Add and export type spec for the json mod

Uman Shahzad 5 years ago
parent
commit
3398e02b89
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/datatypes/epgsql_codec_json.erl

+ 3 - 1
src/datatypes/epgsql_codec_json.erl

@@ -11,9 +11,10 @@
 
 
 -export([init/2, names/0, encode/3, decode/3, decode_text/3]).
 -export([init/2, names/0, encode/3, decode/3, decode_text/3]).
 
 
--export_type([data/0]).
+-export_type([data/0, json_mod/0]).
 
 
 -type data() :: binary().
 -type data() :: binary().
+-type json_mod()::module() | {module(), Encode::any(), DecodeOpts::any()}.
 
 
 -define(JSONB_VERSION_1, 1).
 -define(JSONB_VERSION_1, 1).
 
 
@@ -30,6 +31,7 @@
 
 
 %% JsonMod shall be a module that implements the callbacks defined by this module;
 %% JsonMod shall be a module that implements the callbacks defined by this module;
 %% encode/1, decode/1, and optionally the option-accepting variants.
 %% encode/1, decode/1, and optionally the option-accepting variants.
+-spec init(JsonMod::json_mod(), epgsql_sock:pg_sock()) -> epgsql_codec:codec_state().
 init(JsonMod, _) ->
 init(JsonMod, _) ->
     JsonMod.
     JsonMod.