Crate tf2_enum

Source
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§

error

Structs§

Level
Level belonging to an ItemLevel.
SpellSet
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.
SpellSetIterator
Iterator for spells.
StrangePartSet
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.
StrangePartSetIterator
Iterator for strange parts.

Enums§

Capability
Capability. Not meant for serialization.
Class
Class.
CraftClass
Craft class.
CraftMaterialType
Craft material type.
FootprintsSpell
Footprints spell.
Grade
Grade.
ItemLevel
Item level.
ItemSlot
Item slot.
KillEaterScoreType
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.
KillstreakTier
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.
PaintSpell
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.
StockWeapon
Stock weapons.
StrangePart
Strange part. repr values are mapped to their kill_eater_score_type attribute value. Strings are the name of the kill_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.