kjspkg_api/models/pkg.rs
1use super::User;
2use chrono::NaiveDateTime;
3
4/// A struct representing the fields required to create a package.
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
6pub struct NewPackage {
7 /// This package's slug (URL ID).
8 pub slug: String,
9
10 /// The name of the package.
11 pub name: String,
12
13 /// A short description of the package.
14 pub description: String,
15
16 /// This package's README, a long-form description of the package.
17 pub readme: String,
18
19 /// A link to the source code repository of this package.
20 pub source: Option<String>,
21
22 /// A link to this package's issue tracker.
23 pub issues: Option<String>,
24
25 /// A link to this package's wiki.
26 pub wiki: Option<String>,
27}
28
29/// A struct representing the fields that can be updated in a package.
30#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
31pub struct PackageUpdate {
32 /// The name of the package.
33 pub name: Option<String>,
34
35 /// A short description of the package.
36 pub description: Option<String>,
37
38 /// This package's README, a long-form description of the package.
39 pub readme: Option<String>,
40
41 /// A link to the source code repository of this package.
42 pub source: Option<String>,
43
44 /// A link to this package's issue tracker.
45 pub issues: Option<String>,
46
47 /// A link to this package's wiki.
48 pub wiki: Option<String>,
49}
50
51/// A struct representing a package.
52#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
53pub struct PackageWithData {
54 /// The package's numerical ID.
55 pub id: i32,
56
57 /// This package's slug (URL ID).
58 pub slug: String,
59
60 /// The name of the package.
61 pub name: String,
62
63 /// A short description of the package.
64 pub description: String,
65
66 /// A list of this package's authors.
67 pub authors: Vec<User>,
68
69 /// This package's README, a long-form description of the package.
70 pub readme: String,
71
72 /// A link to the source code repository of this package.
73 pub source: Option<String>,
74
75 /// A link to this package's issue tracker.
76 pub issues: Option<String>,
77
78 /// A link to this package's wiki.
79 pub wiki: Option<String>,
80
81 /// The number of views this package has.
82 pub views: i32,
83
84 /// The number of downloads this package has.
85 pub downloads: i32,
86
87 /// The date/time when this package was created.
88 pub created_at: NaiveDateTime,
89
90 /// The date/time when this package was last updated.
91 pub updated_at: NaiveDateTime,
92}