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
use crate::id::ModuleID;
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct WhoamiResponse {
pub user: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PublishRequest {
pub code: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PublishResponse {
pub author: String,
pub name: String,
pub version: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct DownloadResponse {
pub author: String,
pub name: String,
pub version: String,
pub code: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ModuleInfoResponse {
pub author: String,
pub name: String,
pub description: String,
pub latest: Option<String>,
pub redirect: Option<ModuleID>,
}
impl ModuleInfoResponse {
pub fn canonical(&self) -> String {
format!("{}/{}", self.author, self.name)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SearchResponse {
pub author: String,
pub name: String,
pub description: String,
pub latest: String,
pub downloads: i64,
pub featured: bool,
}
impl SearchResponse {
pub fn canonical(&self) -> String {
format!("{}/{}", self.author, self.name)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LatestResponse {
pub time: Option<u64>,
}