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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! This is the products module accessible from the crate folder. It contains
//! all information related to Minehut products.
//!
//! This module provides functions for:
//!
//! * Retrieving all products from Minehut.
//! * Filtering Minehut products.
//! * Getting products by name or searching for it.
use cratehttp;
use crateProduct;
/// Products can be of 9 different types, this enumerates those
/// specific types for later.
/// Gets all products from Minehut asynchronously.
///
/// # Example
///
/// ```
/// async fn print_expensive_products() -> Result<(), minehut::Error> {
/// use minehut::products;
///
/// // Print all icons with price over 700
/// products::all().await?.into_iter().for_each(|p| {
/// if(p.price > 700) {
/// println!("{} is expensive", p.title);
/// }
/// });
///
/// Ok(())
/// }
/// ```
///
/// # Error
///
/// Returns an error if Reqwest could not fetch the data or if it could not
/// parse the JSON. This is usually a network problem.
pub async
/// Gets all products of a specific category asynchronously.
///
/// # Arguments
///
/// * `category` - Category to filter products with.
///
/// # Example
///
/// ```
/// use minehut::products;
///
/// async fn print_plugins() {
/// // Printing all available plugins
/// products::of_category(products::Category::Plugin).await.unwrap().into_iter().for_each(|p| {
/// println!("{} is a plugin", p.title);
/// })
/// }
/// ```
///
/// # Error
///
/// Returns an error if Reqwest could not fetch the data from path or if it failed
/// to parse JSON. Both of these are usually network errors.
pub async
/// Returns all products which contain a specific name in their title.
///
/// # Arguments
///
/// * `query` - String slice to query products.
///
/// # Example
///
/// ```
/// #[tokio::main]
/// async fn main() {
/// use minehut::products;
///
/// // Getting all products with "Skript" in its name
/// products::search("Skript").await.unwrap().into_iter().for_each(|p| {
/// println!("{}", p.title);
/// })
/// }
/// ```
///
/// # Error
///
/// Returns an error if Reqwest could not fetch data from the path or if it failed
/// to parse the response JSON. Usually network errors.
pub async