Summary

Functions

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

Constructors

Converts an integer into a SteamID.

Like from_integer/2, but raises on invalid inputs.

Constructs a %SteamID{} from its components.

Parses a string into a SteamID.

Like parse/2, but raises on invalid inputs.

Conversions

Converts a SteamID to an integer.

Converts a SteamID to a string.

Types

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.

Functions

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.

Components

account_instance()

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

account_instance(steam_id)

@spec account_instance(t()) :: account_instance()

account_number()

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

account_number(steam_id)

@spec account_number(t()) :: account_number()

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.

account_type(steam_id)

@spec account_type(t()) :: account_type()

authentication_server()

@type authentication_server() :: 0..1

authentication_server(steam_id)

@spec authentication_server(t()) :: authentication_server()

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{}.

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)

universe()

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

The various Steam universes.

universe(steam_id)

@spec universe(t()) :: universe()

Constructors

from_integer(value, opts \\ [])

@spec from_integer(value :: integer(), [option]) :: {:ok, t()} | :error
when option: {:size, 32 | 64}

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, opts \\ [])

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

Like from_integer/2, but raises on invalid inputs.

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>

parse(value, opts \\ [])

@spec parse(binary(), [option]) :: {:ok, t()} | :error
when option: {:format, :id2 | :id3 | :id32 | :id64}

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, opts \\ [])

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

Like parse/2, but raises on invalid inputs.

Conversions

to_integer(steam_id, opts \\ [])

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

Converts a SteamID to an integer.

Options

  • :size (one of 32, 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)