#id #steam-id #steam #parser

steamid-ng

An easy-to-use steamid type with functions to parse and render steam2 and steam3 IDs

9 releases (1 stable)

1.0.0 Oct 4, 2020
0.3.4 Apr 15, 2020
0.3.3 Jul 13, 2019
0.3.1 Nov 24, 2017
0.1.1 Sep 26, 2017

#1747 in Parser implementations

Download history 162/week @ 2024-01-14 144/week @ 2024-01-21 130/week @ 2024-01-28 124/week @ 2024-02-04 147/week @ 2024-02-11 152/week @ 2024-02-18 129/week @ 2024-02-25 125/week @ 2024-03-03 139/week @ 2024-03-10 152/week @ 2024-03-17 134/week @ 2024-03-24 207/week @ 2024-03-31 128/week @ 2024-04-07 125/week @ 2024-04-14 158/week @ 2024-04-21 227/week @ 2024-04-28

663 downloads per month
Used in 7 crates

MIT license

15KB
300 lines

steamid-ng crates.io MIT License Docs.rs Travis CI

An easy-to-use steamid type with functions to parse and render steam2 and steam3 IDs. All credit for the initial PHP implementation goes to xPaw; I merely ported it to rust.


lib.rs:

SteamID

The steamid-ng crate provides an easy-to-use SteamID type with functions to parse and render steam2 and steam3 IDs. It also supports serializing and deserializing via serde.

Examples

let x = SteamID::from(76561197960287930);
let y = SteamID::from_steam3("[U:1:22202]").unwrap();
let z = SteamID::from_steam2("STEAM_1:0:11101").unwrap();
assert_eq!(x, y);
assert_eq!(y, z);

assert_eq!(u64::from(z), 76561197960287930);
assert_eq!(y.steam2(), "STEAM_1:0:11101");
assert_eq!(x.steam3(), "[U:1:22202]");

assert_eq!(x.account_id(), 22202);
assert_eq!(x.instance(), Instance::Desktop);
assert_eq!(x.account_type(), AccountType::Individual);
assert_eq!(x.universe(), Universe::Public);
// the SteamID type also has `set_{account_id, instance, account_type, universe}` methods,
// which work as you would expect.

Keep in mind that the SteamID type does no validation.

Dependencies

~3–4.5MB
~86K SLoC