1use strum_macros::{Display, EnumString, EnumIter, EnumCount};
2use num_enum::{TryFromPrimitive, IntoPrimitive};
3use serde_repr::{Serialize_repr, Deserialize_repr};
4
5#[derive(
7 Serialize_repr,
8 Deserialize_repr,
9 Debug,
10 Hash,
11 Eq,
12 PartialEq,
13 Ord,
14 PartialOrd,
15 Display,
16 EnumString,
17 EnumIter,
18 EnumCount,
19 TryFromPrimitive,
20 IntoPrimitive,
21 Clone,
22 Copy,
23)]
24#[repr(u32)]
25pub enum Origin {
26 #[strum(serialize = "Timed Drop")]
27 TimedDrop = 0,
28 #[strum(serialize = "Achievement")]
29 Achievement = 1,
30 #[strum(serialize = "Purchased")]
31 Purchased = 2,
32 #[strum(serialize = "Traded")]
33 Traded = 3,
34 #[strum(serialize = "Crafted")]
35 Crafted = 4,
36 #[strum(serialize = "Store Promotion")]
37 StorePromotion = 5,
38 #[strum(serialize = "Gifted")]
39 Gifted = 6,
40 #[strum(serialize = "Support Granted")]
41 SupportGranted = 7,
42 #[strum(serialize = "Found in Crate")]
43 FoundInCrate = 8,
44 #[strum(serialize = "Earned")]
45 Earned = 9,
46 #[strum(serialize = "Third-Party Promotion")]
47 ThirdPartyPromotion = 10,
48 #[strum(serialize = "Wrapped Gift")]
49 WrappedGift = 11,
50 #[strum(serialize = "Halloween Drop")]
51 HalloweenDrop = 12,
52 #[strum(serialize = "Steam Purchase")]
53 SteamPurchase = 13,
54 #[strum(serialize = "Foreign Item")]
55 ForeignItem = 14,
56 #[strum(serialize = "CD Key")]
57 CDKey = 15,
58 #[strum(serialize = "Collection Reward")]
59 CollectionReward = 16,
60 #[strum(serialize = "Preview Item")]
61 PreviewItem = 17,
62 #[strum(serialize = "Steam Workshop Contribution")]
63 SteamWorkshopContribution = 18,
64 #[strum(serialize = "Periodic score reward")]
65 PeriodicScoreReward = 19,
66 #[strum(serialize = "MvM Badge completion reward")]
67 MvMBadgeCompletionReward = 20,
68 #[strum(serialize = "MvM Squad surplus reward")]
69 MvMSquadSurplusReward = 21,
70 #[strum(serialize = "Recipe output")]
71 RecipeOutput = 22,
72 #[strum(serialize = "Quest Drop")]
73 QuestDrop = 23,
74 #[strum(serialize = "Quest Loaner Item")]
75 QuestLoanerItem = 24,
76 #[strum(serialize = "Trade-Up")]
77 TradeUp = 25,
78 #[strum(serialize = "Viral Competitive Beta Pass Spread")]
79 ViralCompetitiveBetaPassSpread = 26,
80 #[strum(serialize = "CYOA Blood Money Purchase")]
81 CYOABloodMoneyPurchase = 27,
82 #[strum(serialize = "War Paint")]
83 WarPaint = 28,
84 #[strum(serialize = "Untradable Free Contract Reward")]
85 UntradableFreeContractReward = 29,
86}
87
88#[cfg(test)]
89mod tests {
90 use super::*;
91 use std::str::FromStr;
92
93 #[test]
94 fn test_from_str() {
95 assert_eq!(Origin::from_str("Purchased").unwrap(), Origin::Purchased);
96 }
97
98 #[test]
99 fn test_try_from_primitive() {
100 assert_eq!(Origin::try_from(2u32).unwrap(), Origin::Purchased);
101 }
102}