#steam #parser #steamid

steamid-ng

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

7 releases

0.3.1 Nov 24, 2017
0.3.0 Nov 21, 2017
0.2.2 Nov 20, 2017
0.1.2 Oct 11, 2017
0.1.1 Sep 26, 2017

#78 in Parser implementations

Download history 7/week @ 2018-08-22 8/week @ 2018-09-05 1/week @ 2018-09-12 7/week @ 2018-09-26 21/week @ 2018-10-03 69/week @ 2018-10-17 7/week @ 2018-10-24 49/week @ 2018-11-07

39 downloads per month

MIT license

14KB
305 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

# use steamid_ng::{SteamID, Instance, AccountType, Universe};
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.5MB
~65K SLoC