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
extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Clone)] pub struct AuditRequestPackage { pub source: String, pub name: String, pub version: String, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AuditRequest { pub packages: Vec<AuditRequestPackage>, pub token: Option<String>, } #[derive(Debug, Serialize, Deserialize, Default, Clone, Copy)] pub struct UsageStatsItem { pub bad: i64, pub good: i64, pub used: i64, } impl UsageStatsItem { pub fn empty() -> Self { UsageStatsItem { bad: 0, good: 0, used: 0, } } } #[derive(Debug, Serialize, Deserialize, Default, Clone)] pub struct UsageStats { pub patch: UsageStatsItem, pub minor: UsageStatsItem, pub major: UsageStatsItem, pub total: UsageStatsItem, } impl UsageStats { pub fn empty() -> Self { UsageStats { patch: UsageStatsItem::empty(), minor: UsageStatsItem::empty(), major: UsageStatsItem::empty(), total: UsageStatsItem::empty(), } } } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AuditResponsePackage { pub stats: UsageStats, pub self_score_good: bool, pub self_score_bad: bool, pub url: Option<String>, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AuditResponse { pub packages: Vec<Result<AuditResponsePackage, String>>, pub username: Option<String>, }