1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use serde_repr::Serialize_repr;
#[derive(Debug, Clone, PartialEq)]
pub struct MarketFilter<'a> {
pub sort_type: SortBy,
pub sort_direction: SortDirection,
pub currency: Currency,
pub min_price: Option<u64>,
pub max_price: Option<u64>,
pub min_quantity: Option<u64>,
pub max_quantity: Option<u64>,
pub min_condition: Option<u64>,
pub max_condition: Option<u64>,
pub expiring_within_hour: bool,
pub hide_bartering_offers: bool,
pub owner_type: Owner,
pub hide_inoperable_weapons: bool,
pub handbook_id: Option<&'a str>,
pub linked_search_id: Option<&'a str>,
pub required_search_id: Option<&'a str>,
}
#[derive(Serialize_repr, Debug, Clone, PartialEq)]
#[repr(u8)]
pub enum SortBy {
ID = 0,
BarteringOffers = 2,
MerchantRating = 3,
Price = 5,
Expiry = 6,
}
#[derive(Serialize_repr, Debug, Clone, PartialEq)]
#[repr(u8)]
pub enum SortDirection {
Ascending = 0,
Descending = 1,
}
#[derive(Serialize_repr, Debug, Clone, PartialEq)]
#[repr(u8)]
pub enum Currency {
Any = 0,
Rouble = 1,
Dollar = 2,
Euro = 3,
}
#[derive(Serialize_repr, Debug, Clone, PartialEq)]
#[repr(u8)]
pub enum Owner {
Any = 0,
Traders = 1,
Player = 2,
}
impl<'a> Default for MarketFilter<'a> {
fn default() -> Self {
Self {
sort_type: SortBy::Price,
sort_direction: SortDirection::Ascending,
currency: Currency::Any,
min_price: None,
max_price: None,
min_quantity: None,
max_quantity: None,
min_condition: None,
max_condition: Some(100),
expiring_within_hour: false,
hide_bartering_offers: false,
owner_type: Owner::Any,
hide_inoperable_weapons: true,
handbook_id: None,
linked_search_id: None,
required_search_id: None,
}
}
}