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
use crate::models::v2::package;
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Community {
pub identifier: String,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub discord_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub wiki_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub require_package_listing_approval: Option<bool>,
}
impl Community {
#[must_use]
pub fn new(identifier: String, name: String) -> Community {
Community {
identifier,
name,
discord_url: None,
wiki_url: None,
require_package_listing_approval: None,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct PackageList {
pub bg_image_src: Option<String>,
pub categories: Vec<package::Category>,
pub community_name: String,
pub has_more_pages: bool,
pub packages: Vec<package::Card>,
}
impl PackageList {
#[must_use]
pub fn new(
bg_image_src: Option<String>,
categories: Vec<package::Category>,
community_name: String,
has_more_pages: bool,
packages: Vec<package::Card>,
) -> PackageList {
PackageList {
bg_image_src,
categories,
community_name,
has_more_pages,
packages,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Card {
pub bg_image_src: Option<String>,
pub download_count: u32,
pub identifier: String,
pub name: String,
pub package_count: u32,
}
impl Card {
#[must_use]
pub fn new(
bg_image_src: Option<String>,
download_count: u32,
identifier: String,
name: String,
package_count: u32,
) -> Card {
Card {
bg_image_src,
download_count,
identifier,
name,
package_count,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct ListResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub next: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub previous: Option<String>,
pub results: Vec<Community>,
}
impl ListResponse {
#[must_use]
pub fn new(results: Vec<Community>) -> ListResponse {
ListResponse {
next: None,
previous: None,
results,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CategoryListResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub next: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub previous: Option<String>,
pub results: Vec<package::Category>,
}
impl CategoryListResponse {
#[must_use]
pub fn new(results: Vec<package::Category>) -> CategoryListResponse {
CategoryListResponse {
next: None,
previous: None,
results,
}
}
}