1use crate::id::ModuleID;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize)]
5pub struct WhoamiResponse {
6 pub user: String,
7}
8
9#[derive(Debug, Serialize, Deserialize)]
10pub struct PublishRequest {
11 pub code: String,
12}
13
14#[derive(Debug, Serialize, Deserialize)]
15pub struct PublishResponse {
16 pub author: String,
17 pub name: String,
18 pub version: String,
19}
20
21#[derive(Debug, Serialize, Deserialize)]
22pub struct DownloadResponse {
23 pub author: String,
24 pub name: String,
25 pub version: String,
26 pub code: String,
27}
28
29#[derive(Debug, Serialize, Deserialize)]
30pub struct ModuleInfoResponse {
31 pub author: String,
32 pub name: String,
33 pub description: String,
34 pub latest: Option<String>,
35 pub redirect: Option<ModuleID>,
36}
37
38impl ModuleInfoResponse {
39 pub fn canonical(&self) -> String {
40 format!("{}/{}", self.author, self.name)
41 }
42}
43
44#[derive(Debug, Serialize, Deserialize)]
45pub struct SearchResponse {
46 pub author: String,
47 pub name: String,
48 pub description: String,
49 pub latest: String,
50 pub downloads: i64,
51 pub featured: bool,
52}
53
54impl SearchResponse {
55 pub fn canonical(&self) -> String {
56 format!("{}/{}", self.author, self.name)
57 }
58}
59
60#[derive(Debug, Serialize, Deserialize)]
61pub struct LatestResponse {
62 pub time: Option<u64>,
63}