SteamID (SteamID v0.4.0)

View Source

Valve's SteamID format.

Summary

Types

The various Steam account types.

The components that make up a %SteamID{}.

t()

A SteamID.

The various Steam universes.

Functions

Converts an integer into a SteamID.

Like from_integer/1, but raises on invalid inputs.

Constructs a %SteamID{} from its components.

Resets the given SteamID's components to the values expected for regular user accounts.

Parses a string into a SteamID.

Like parse/1, but raises on invalid inputs.

Converts a SteamID to an integer.

Converts a SteamID to a string.

Types

account_instance()

@type account_instance() :: 0..1_048_575

account_number()

@type account_number() :: 0..2_147_483_647

account_type()

@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.

authentication_server()

@type authentication_server() :: 0..1

component()

@type component() ::
  {:universe, universe()}
  | {:account_type, account_type()}
  | {:account_instance, account_instance()}
  | {:account_number, account_number()}
  | {:authentication_server, authentication_server()}

The components that make up a %SteamID{}.

steamid32()

@type steamid32() :: 0..4_294_967_295

steamid64()

@type steamid64() :: 0..409_827_566_090_715_135

t()

@type t() :: %SteamID{value: term()}

A SteamID.

You may pattern match on this struct, but not read or write its fields. Use the functions in this module instead.

universe()

@type universe() ::
  :unspecified | :individual | :public | :beta | :internal | :dev | :rc

The various Steam universes.

Functions

from_integer(value)

@spec from_integer(value :: integer()) :: {:ok, t()} | :error
@spec from_integer(steamid32()) :: {:ok, t()}
@spec from_integer(steamid64()) :: {:ok, t()}

Converts an integer into a SteamID.

Examples

iex> {:ok, steam_id} = SteamID.from_integer(76561198282622073)
iex> steam_id
#SteamID<76561198282622073>
iex> {:ok, steam_id} = SteamID.from_integer(322356345)
iex> steam_id
#SteamID<4503604244694137>
iex> {:ok, steam_id} = SteamID.from_integer(322356345)
iex> SteamID.normalize(steam_id)
#SteamID<76561198282622073>
iex> :error = SteamID.from_integer(-42)
:error

from_integer!(value)

@spec from_integer!(value :: integer()) :: t()

Like from_integer/1, but raises on invalid inputs.

is_account_id(term)

(macro)

is_account_instance(term)

(macro)

is_account_number(term)

(macro)

is_account_type(term)

(macro)

is_authentication_server(term)

(macro)

is_steamid32(term)

(macro)

is_steamid64(term)

(macro)

is_universe(term)

(macro)

new(components \\ [])

@spec new([component()]) :: t()

Constructs a %SteamID{} from its components.

Examples

iex> SteamID.new(account_number: 161178172, authentication_server: 1)
#SteamID<4503604244694137>
iex> SteamID.new(account_number: 161178172, authentication_server: 1)
...> |> SteamID.normalize()
#SteamID<76561198282622073>

nimble_options(overrides \\ [])

@spec nimble_options(keyword()) :: keyword()

normalize(steam_id)

@spec normalize(t()) :: t()

Resets the given SteamID's components to the values expected for regular user accounts.

parse(value)

@spec parse(binary()) :: {:ok, t()} | :error

Parses a string into a SteamID.

Examples

iex> with {:ok, steam_id} = SteamID.parse("76561198282622073"), do: steam_id
#SteamID<76561198282622073>
iex>  with {:ok, steam_id} = SteamID.parse("STEAM_1:1:161178172"), do: steam_id
#SteamID<76561198282622073>
iex> SteamID.parse("bingus")
:error

parse!(value)

@spec parse!(binary()) :: t()

Like parse/1, but raises on invalid inputs.

to_integer(steam_id, opts \\ [])

@spec to_integer(t(), [option]) :: integer() when option: {:size, 32 | 64}

Converts a SteamID to an integer.

Options

  • :size (32 or 64) - The default value is 64.

to_string(steam_id, opts \\ [])

@spec to_string(t(), [option]) :: String.t()
when option: {:format, :id2 | :id3 | :id32 | :id64}

Converts a SteamID to a string.

Options

  • :format (one of :id2, :id3, :id32, :id64) - The default value is :id64.