1use std::collections::HashMap;
2use serde::{Deserialize, Serialize};
3
4#[derive(Default, Debug, Serialize, Deserialize)]
5pub struct CratesIoResponse {
6 #[serde(rename = "crate")]
7 pub crate_info: Crate,
8 pub versions: Vec<Version>,
9 pub keywords: Vec<Keyword>,
10 pub categories: Vec<Category>,
11}
12
13#[derive(Default, Debug, Serialize, Deserialize)]
14pub struct Crate {
15 pub id: String,
16 pub name: String,
17 pub updated_at: String,
18 pub versions: Vec<u64>,
19 pub keywords: Vec<String>,
20 pub categories: Vec<String>,
21 pub badges: Vec<String>,
22 pub created_at: String,
23 pub downloads: u64,
24 pub recent_downloads: Option<u64>,
25 pub default_version: String,
26 pub num_versions: u32,
27 pub yanked: bool,
28 pub max_version: String,
29 pub newest_version: String,
30 pub max_stable_version: String,
31 pub description: Option<String>,
32 pub homepage: Option<String>,
33 pub documentation: Option<String>,
34 pub repository: Option<String>,
35 pub links: CrateLinks,
36 pub exact_match: bool,
37}
38
39#[derive(Default, Debug, Serialize, Deserialize)]
40pub struct CrateLinks {
41 pub version_downloads: String,
42 pub versions: Option<String>,
43 pub owners: String,
44 pub owner_team: String,
45 pub owner_user: String,
46 pub reverse_dependencies: String,
47}
48
49#[derive(Default, Debug, Serialize, Deserialize)]
50pub struct Version {
51 pub id: u64,
52 #[serde(rename = "crate")]
53 pub crate_name: String,
54 pub num: String,
55 pub dl_path: String,
56 pub readme_path: String,
57 pub updated_at: String,
58 pub created_at: String,
59 pub downloads: u64,
60 pub features: HashMap<String, Vec<String>>,
61 pub yanked: bool,
62 pub yank_message: Option<String>,
63 pub lib_links: Option<String>,
64 pub license: Option<String>,
65 pub links: VersionLinks,
66 pub crate_size: u64,
67 pub published_by: Option<User>,
68 pub audit_actions: Vec<AuditAction>,
69 pub checksum: String,
70 pub rust_version: Option<String>,
71 pub has_lib: Option<bool>,
72 pub bin_names: Option<Vec<String>>,
73 pub edition: Option<String>,
74 pub description: Option<String>,
75 pub homepage: Option<String>,
76 pub documentation: Option<String>,
77 pub repository: Option<String>,
78 pub trustpub_data: Option<TrustpubData>,
79}
80
81#[derive(Default, Debug, Serialize, Deserialize)]
82pub struct VersionLinks {
83 pub dependencies: String,
84 pub version_downloads: String,
85 pub authors: String,
86}
87
88#[derive(Default, Debug, Serialize, Deserialize)]
89pub struct User {
90 pub id: u64,
91 pub login: String,
92 pub name: Option<String>,
93 pub avatar: String,
94 pub url: String,
95}
96
97#[derive(Default, Debug, Serialize, Deserialize)]
98pub struct AuditAction {
99 pub action: String,
100 pub user: User,
101 pub time: String,
102}
103
104#[derive(Default, Debug, Serialize, Deserialize)]
105pub struct TrustpubData {
106 pub provider: String,
107 pub repository: String,
108 pub run_id: String,
109 pub sha: String
110}
111
112#[derive(Default, Debug, Serialize, Deserialize)]
113pub struct Keyword {
114 pub id: String,
115 pub keyword: String,
116 pub created_at: String,
117 pub crates_cnt: u32,
118}
119
120#[derive(Default, Debug, Serialize, Deserialize)]
121pub struct Category {
122 pub id: String,
123 pub category: String,
124 pub slug: String,
125 pub description: String,
126 pub created_at: String,
127 pub crates_cnt: u32,
128}