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