SteamID (SteamID v0.1.1)
View SourceValve's SteamID.
Summary
Functions
A struct carrying all components of a SteamID.
Converts an integer to a %SteamID{}.
Creates a new %SteamID{}.
Normalizes the given %SteamID{} by setting universe, account_type, and account_instance to
their default values.
Converts a string to a %SteamID{}.
Converts a %SteamID{} to an integer.
Converts a %SteamID{} to a string.
Types
@type account_instance() :: non_neg_integer()
@type account_number() :: non_neg_integer()
@type account_type() ::
:invalid
| :individual
| :multiseat
| :game_server
| :anon_game_server
| :pending
| :content_server
| :clan
| :chat
| :p2p_super_seeder
| :anon_user
The various Steam account types.
@type authentication_server() :: 0 | 1
@type format() :: :id2 | :id3 | :id32 | :id64
@type size() :: 32 | 64
@type t() :: %SteamID{ account_instance: account_instance(), account_number: account_number(), account_type: account_type(), authentication_server: authentication_server(), universe: universe() }
A SteamID.
@type universe() ::
(:unspecified | :individual) | :public | :beta | :internal | :dev | :rc
The various Steam universes.
Functions
A struct carrying all components of a SteamID.
You may read all fields, but only change them by calling functions in the SteamID module.
Converts an integer to a %SteamID{}.
Example
iex> SteamID.from_integer(0)
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 0,
authentication_server: 0
}}
iex> SteamID.from_integer(76561198282622073)
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}}
iex> SteamID.from_integer(322356345)
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}}
iex> SteamID.from_integer(-42)
:error
@spec new([field]) :: t() when field: {:universe, universe()} | {:account_type, account_type()} | {:account_instance, account_instance()} | {:account_number, account_number()} | {:authentication_server, authentication_server()}
Creates a new %SteamID{}.
Example
iex> SteamID.new()
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 0,
authentication_server: 0
}
iex> SteamID.new(account_number: 161178172, authentication_server: 1)
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}Fields
:universe(universe/0):account_type(account_type/0):account_instance(account_instance/0):account_number(account_number/0):authentication_server(authentication_server/0)
Normalizes the given %SteamID{} by setting universe, account_type, and account_instance to
their default values.
Converts a string to a %SteamID{}.
Example
iex> SteamID.parse("0")
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 0,
authentication_server: 0
}}
iex> SteamID.parse("U:1:322356345")
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}}
iex> SteamID.parse("STEAM_1:1:161178172")
{:ok,
%SteamID{
universe: :public,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}}
iex> SteamID.parse("STEAM_0:1:161178172")
{:ok,
%SteamID{
universe: :unspecified,
account_type: :individual,
account_instance: 1,
account_number: 161178172,
authentication_server: 1
}}
iex> SteamID.parse("bingus")
:error
Converts a %SteamID{} to an integer.
Example
iex> steam_id = SteamID.new(account_number: 161178172, authentication_server: 1)
iex> SteamID.to_integer(steam_id, size: 32)
322356345
iex> SteamID.to_integer(steam_id, size: 64)
76561198282622073Options
:size(size/0) - The default value is64.
Converts a %SteamID{} to a string.
Example
iex> steam_id = SteamID.new(account_number: 161178172, authentication_server: 1)
iex> SteamID.to_string(steam_id, format: :id2)
"STEAM_1:1:161178172"
iex> SteamID.to_string(steam_id, format: :id3)
"U:1:322356345"
iex> SteamID.to_string(steam_id, format: :id32)
"322356345"
iex> SteamID.to_string(steam_id, format: :id64)
"76561198282622073"Options
:format(format/0) - The default value is:id64.
When called with the default options, this function is equivalent to Kernel.to_string/1.