#parser #string-parser #fortress #team #steam

tf2-sku

SKU parser for Team Fortress 2 items

7 releases (4 breaking)

0.5.0 Aug 3, 2024
0.4.2 May 14, 2024
0.4.1 Feb 10, 2024
0.4.0 Oct 8, 2023
0.1.0 Jul 10, 2022

#3 in #fortress

MIT license

57KB
1K SLoC

tf2-sku

For parsing attributes from SKU strings.

Usage

use tf2_sku::SKU;
use tf2_enum::{Quality, KillstreakTier, Spell, StrangePart};

let sku = "264;11;kt-1".parse::<SKU>().unwrap();

assert_eq!(sku.defindex, 264);
assert_eq!(sku.quality, Quality::Strange);
assert_eq!(sku.killstreak_tier, Some(KillstreakTier::Killstreak));
assert_eq!(sku.to_string(), "264;11;kt-1");

// Also supports spells and strange parts
let sku = "627;11;footprints-2;sp-28".parse::<SKU>().unwrap();

assert!(sku.spells.contains(&Spell::HeadlessHorseshoes));
assert!(sku.strange_parts.contains(&StrangePart::Dominations));

License

MIT


lib.rs:

tf2-sku

SKU parser for Team Fortress 2 items.

Usage

use tf2_sku::SKU;
use tf2_sku::tf2_enum::{Quality, KillstreakTier, Spell};

let sku = "264;11;kt-1".parse::<SKU>().unwrap();

assert_eq!(sku.defindex, 264);
assert_eq!(sku.quality, Quality::Strange);
assert_eq!(sku.killstreak_tier, Some(KillstreakTier::Killstreak));
assert_eq!(sku.to_string(), "264;11;kt-1");

// Also supports spells and strange parts
let sku = "627;6;footprints-2".parse::<SKU>().unwrap();

assert!(sku.spells.contains(&Spell::HeadlessHorseshoes));

Dependencies

~0.5–1MB
~24K SLoC