Expand description
Provides enumerated types for models related to the Team Fortress 2 item schema.
For the most part, definitions here are relatively stable and don’t have any new values added or changed. However, Valve can implement changes to the item schema at any time, which may affect some of the values defined here.
Definitions for things that are often updated like items, attributes, skins, and particles are not included.
§Usage
use tf2_enum::{Quality, Spell, ItemLevel, KillstreakTier};
use std::str::FromStr;
assert_eq!("Unusual".parse::<Quality>().unwrap(), Quality::Unusual);
assert_eq!(Quality::Unusual as u32, 5);
assert_eq!(Spell::HalloweenFire.to_string(), "Halloween Fire");
let level = ItemLevel::KillEaterRank.score_level(9000);
let killstreak_tier = KillstreakTier::Professional;
let full_name = format!("{level} {killstreak_tier} Pomson 6000");
assert_eq!(full_name, "Hale's Own Professional Killstreak Pomson 6000");
Re-exports§
pub use num_enum;
pub use strum;
pub use strum_macros;
Modules§
Structs§
- Level
- Level belonging to an
ItemLevel
. - Spell
Set - Contains up to 2 spells. Although the underlying data structure is an array, this structure
behaves like a set. Most methods mimic those of
HashSet
. - Spell
SetIterator - Iterator for spells.
- Strange
Part Set - Contains up to 3 strange parts. Although the underlying data structure is an array, this structure
behaves like a set. Most methods mimic those of
HashSet
. - Strange
Part SetIterator - Iterator for strange parts.
Enums§
- Capability
- Capability. Not meant for serialization.
- Class
- Class.
- Craft
Class - Craft class.
- Craft
Material Type - Craft material type.
- Footprints
Spell - Footprints spell.
- Grade
- Grade.
- Item
Level - Item level.
- Item
Slot - Item slot.
- Kill
Eater Score Type - Kill eater score type. Conversion from strings is not supported due to multiple variants having the same string representation. They can still be formatted into strings.
- Killstreak
Tier - Killstreak tier.
- Killstreaker
- Killstreaker.
- Origin
- Origin.
- Paint
- Paint.
repr
values are mapped to the corresponding color. For team paints this is the color for RED team. - Paint
Spell - Paint spell.
- Quality
- Quality.
- Sheen
- Sheen.
- Spell
- Spell. In the schema, spells aren’t grouped together because they have different attributes, though in practice they’re often treated as if they are.
- Stock
Weapon - Stock weapons.
- Strange
Part - Strange part.
repr
values are mapped to theirkill_eater_score_type
attribute value. Strings are the name of thekill_eater_score_type
, not the name of the strange part. - Wear
- Wear.
Traits§
- Attribute
- Attribute values for an item attribute.
- Attributes
- Associated attribute values for a set of item attributes.