refactor(spec): add type specs

This commit is contained in:
Anthony Mineo 2022-04-13 17:48:55 -04:00
parent a500fea095
commit 7392039071
3 changed files with 19 additions and 4 deletions

View file

@ -66,7 +66,7 @@ defmodule T2ServerQuery.PacketParser do
}
end
@spec init(binary(), binary()) :: {:ok, %QueryResult{}}
@spec init(binary(), binary()) :: {:ok, QueryResult.t()}
def init(info_packet, status_packet) when is_binary(info_packet) and is_binary(status_packet) do
info_results = info_packet
@ -83,7 +83,7 @@ defmodule T2ServerQuery.PacketParser do
pack_results({:ok, status_results, info_results})
end
@spec pack_results({:ok, map(), map()}) :: {:ok, %QueryResult{}}
@spec pack_results({:ok, map(), map()}) :: {:ok, QueryResult.t()}
defp pack_results({:ok, status_results, info_results}) do
results = %QueryResult{}

View file

@ -48,6 +48,21 @@ defmodule T2ServerQuery.QueryResult do
}
"""
@type t() :: %__MODULE__{
server_status: atom(),
server_name: String.t(),
game_type: String.t(),
mission_type: String.t(),
map_name: String.t(),
player_count: integer(),
max_player_count: integer(),
bot_count: integer(),
server_description: String.t(),
team_count: integer(),
teams: list(),
players: list()
}
defstruct [
server_status: :offline,
server_name: "",