tf2_enum/
lib.rs

1//! Provides enumerated types for models related to the Team Fortress 2 item schema. Other
2//! utilities relating to the schema are also included, as well as related item and
3//! attribute conversion helpers. This crate provides a number of additional attributes mostly
4//! related to trading.
5//! 
6//! For the most part, definitions here are relatively stable and don't have any new values added
7//! or changed. However, Valve can implement changes to the item schema at any time, which may
8//! affect some of the values defined here.
9//! 
10//! Definitions for things that are often updated like items, skins, and particles are
11//! not included.
12//! 
13//! ## Usage
14//! 
15//! ```
16//! use tf2_enum::{Quality, Spell, ItemLevel, KillstreakTier, IntoEnumIterator};
17//! use std::str::FromStr;
18//! 
19//! assert_eq!("Unusual".parse::<Quality>().unwrap(), Quality::Unusual);
20//! assert_eq!(Quality::Unusual as u32, 5);
21//! assert_eq!(Spell::HalloweenFire.to_string(), "Halloween Fire");
22//! 
23//! let level = ItemLevel::KillEaterRank.score_level(9000);
24//! let killstreak_tier = KillstreakTier::Professional;
25//! let full_name = format!("{level} {killstreak_tier} Pomson 6000");
26//! 
27//! assert_eq!(full_name, "Hale's Own Professional Killstreak Pomson 6000");
28//! 
29//! /// Iterate over all quality values.
30//! for quality in Quality::iter() {
31//!     println!("{quality}");
32//! }
33//! ```
34
35#![warn(missing_docs)]
36
37pub mod econ_attributes;
38pub mod error;
39pub mod prelude;
40
41mod attribute_def;
42mod attribute_value;
43mod capability;
44mod class;
45mod craft_class;
46mod craft_material_type;
47mod description_format;
48mod effect_type;
49mod grade;
50mod item_attribute;
51mod item_level;
52mod item_slot;
53mod kill_eater_score_type;
54mod killstreak_tier;
55mod killstreaker;
56mod origin;
57mod paint;
58mod quality;
59mod sheen;
60mod spell;
61mod spell_set;
62mod stock_weapon;
63mod serialize;
64mod strange_part;
65mod strange_part_set;
66mod traits;
67mod wear;
68
69// Traits and utility re-exports
70pub use strum::{EnumCount, IntoEnumIterator};
71pub use num_enum::{IntoPrimitive, TryFromPrimitive};
72pub use traits::{
73    Attribute,
74    Attributes,
75    AttributeSet,
76    TryFromIntAttributeValue,
77    Colored,
78    HasItemDefindex
79};
80
81// Enum re-exports
82pub use attribute_def::AttributeDef;
83pub use attribute_value::AttributeValue;
84pub use capability::Capability;
85pub use class::Class;
86pub use craft_class::CraftClass;
87pub use craft_material_type::CraftMaterialType;
88pub use description_format::DescriptionFormat;
89pub use effect_type::EffectType;
90pub use grade::Grade;
91pub use item_attribute::ItemAttribute;
92pub use item_level::{ItemLevel, Level};
93pub use item_slot::ItemSlot;
94pub use kill_eater_score_type::KillEaterScoreType;
95pub use killstreak_tier::KillstreakTier;
96pub use killstreaker::Killstreaker;
97pub use origin::Origin;
98pub use paint::Paint;
99pub use quality::Quality;
100pub use sheen::Sheen;
101pub use spell::{FootprintsSpell, PaintSpell, Spell};
102pub use spell_set::{SpellSet, SpellSetIterator};
103pub use stock_weapon::StockWeapon;
104pub use strange_part::StrangePart;
105pub use strange_part_set::{StrangePartSet, StrangePartSetIterator};
106pub use wear::Wear;