Skip to content

Commit

Permalink
chore: fix some of the types
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Dec 1, 2023
1 parent be9df94 commit 4fa4fcc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 22 deletions.
16 changes: 8 additions & 8 deletions include/quicer_types.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
, key := file:filename()
, keyfile := file:filename()
, verify => none | peer | verify_peer | verify_none
, cacertfile => filelib:filename()
, cacertfile => file:filename()
, password => string()
, sslkeylogfile => filelib:filename()
, sslkeylogfile => file:filename()
, allow_insecure => boolean()
, quic_registration => reg_handle()
, conn_acceptors => non_neg_integer()
Expand Down Expand Up @@ -141,16 +141,16 @@

-type conn_opts() :: quic_settings() | #{ alpn := [string()]
, conn_callback => module()
, cert => filelib:filename()
, certfile => filelib:filename()
, key => filelib:filename()
, keyfile => filelib:filename()
, cert => file:filename()
, certfile => file:filename()
, key => file:filename()
, keyfile => file:filename()
, password => string()
, verify => none | peer
, handle => connection_handle() %% get NST from last connection, for reconnect.
, nst => binary()
, cacertfile => filelib:filename()
, sslkeylogfile => filelib:filename()
, cacertfile => file:filename()
, sslkeylogfile => file:filename()
, peer_bidi_stream_count => uint16()
, peer_unidi_stream_count => uint16()
, handshake_idle_timeout_ms => non_neg_integer()
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
]}.

{dialyzer, [
{warnings, [unmatched_returns, error_handling, no_unknown]},
{warnings, [unmatched_returns, error_handling]},
{plt_apps, all_apps},
{statistics, true}
]
Expand Down
18 changes: 15 additions & 3 deletions src/quicer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,20 @@
%% versions
-export([abi_version/0]).

-type connection_opts() :: proplists:proplist() | quicer_connection:opts().
-type listener_opts() :: proplists:proplist() | quicer_listener:listener_opts().

%% export types
-export_type([listener_handle/0,
listener_opts/0,
connection_handle/0,
conn_opts/0,
stream_handle/0,
stream_opts/0
]).



-type connection_opts() :: proplists:proplist() | conn_opts().
-type listener_opts() :: proplists:proplist() | listen_opts().

%% @doc Return ABI version of the library.
-spec abi_version() -> quicer_nif:abi_version().
Expand Down Expand Up @@ -288,7 +300,7 @@ listen(ListenOn, Opts) when is_map(Opts) ->
close_listener(Listener) ->
close_listener(Listener, 5000).

-spec close_listener(listener_handle(), timer:time()) ->
-spec close_listener(listener_handle(), timeout()) ->
ok | {error, badarg | closed | timeout}.
close_listener(Listener, Timeout) ->
case quicer_nif:close_listener(Listener) of
Expand Down
2 changes: 1 addition & 1 deletion src/quicer_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ start_link(CallbackModule, {_Host, _Port} = Peer, {_COpts, _SOpts} = Opts) when
%% Get `CallbackModule` from conn_opts, key:`conn_callback` if `CallbackModule` is undefined,
%% this is the entry for supervised acceptor.
-spec start_link(CallbackModule :: undefined | module(),
Listener ::quicer:listener_handle(),
Listener :: quicer:listener_handle(),
ConnOpts :: term(),
Sup :: pid()) -> {ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
Expand Down
1 change: 1 addition & 0 deletions src/quicer_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-include("quicer_types.hrl").

-export_type([ cb_ret/0
, cb_state/0
]).
-type cb_ret() :: cb_ret_noreply() | cb_ret_reply().
-type cb_state() :: term().
Expand Down
6 changes: 3 additions & 3 deletions src/quicer_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
-spec start_link(Name :: listener_name(),
ListenOn :: listen_on(),
Options ::
{ listener_opts()
, quicer_connection:opts()
, quicer_stream:stream_opts()
{ quicer:listener_opts()
, quicer:conn_opts()
, quicer:stream_opts()
}
) -> {ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
Expand Down
2 changes: 1 addition & 1 deletion src/quicer_nif.erl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ controlling_process(_H, _P) ->
erlang:nif_error(nif_library_not_loaded).

-spec peercert(connection_handle() | stream_handle()) ->
{ok, Cert:: public_key:der_encoded()} | {error, any()}.
{ok, Cert :: public_key:der_encoded()} | {error, any()}.
peercert(_Handle) ->
erlang:nif_error(nif_library_not_loaded).

Expand Down
10 changes: 5 additions & 5 deletions src/quicer_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@

-define(post_init, post_init).

-type state() :: #{ stream := quicer:stream_handle()
, conn := quicer:connection_handle()
-type state() :: #{ stream := stream_handle()
, conn := connection_handle()
, callback := atom()
, callback_state := term()
, is_owner := boolean()
Expand All @@ -123,7 +123,7 @@
%%--------------------------------------------------------------------
%% Start acceptor or Start new local stream
-spec start_link(Callback :: module(),
Conn :: quicer:connection_handle(),
Conn :: connection_handle(),
StreamOpts :: map()) -> {ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
{error, Error :: term()} |
Expand All @@ -136,8 +136,8 @@ start_link(Callback, Conn, StreamOpts) when is_atom(Callback) ->
%% then handoff ownership to this process
%%--------------------------------------------------------------------
-spec start_link(Callback :: module(),
Stream :: quicer:connection_handle(),
Conn :: quicer:connection_handle(),
Stream :: connection_handle(),
Conn :: connection_handle(),
StreamOpts :: map(),
Props :: new_stream_props()
) -> {ok, Pid :: pid()} |
Expand Down

0 comments on commit 4fa4fcc

Please sign in to comment.