mirrors_arch/response/
external.rs1use std::fmt::Display;
2
3#[cfg(feature = "time")]
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
8pub(crate) struct Root {
9 pub cutoff: u32,
10 #[cfg(feature = "time")]
11 pub last_check: DateTime<Utc>,
12 #[cfg(not(feature = "time"))]
13 pub last_check: String,
14 pub num_checks: u8,
15 pub check_frequency: u16,
16 pub urls: Vec<Url>,
17 pub version: u8,
18}
19
20#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
21pub(crate) struct Url {
22 pub url: String,
23 pub protocol: Protocol,
24 #[cfg(feature = "time")]
25 pub last_sync: Option<DateTime<Utc>>,
26 #[cfg(not(feature = "time"))]
27 pub last_sync: Option<String>,
28 pub completion_pct: f32,
29 pub delay: Option<i64>,
30 pub duration_avg: Option<f64>,
31 pub duration_stddev: Option<f64>,
32 pub score: Option<f64>,
33 pub active: bool,
34 pub country: String,
35 pub country_code: String,
36 pub isos: bool,
37 pub ipv4: bool,
38 pub ipv6: bool,
39 pub details: String,
40}
41
42#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)]
43#[serde(rename_all = "lowercase")]
44pub enum Protocol {
46 Rsync,
48 Http,
50 Https,
52 Ftp,
54}
55
56impl Display for Protocol {
57 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58 write!(
59 f,
60 "{}",
61 match self {
62 Protocol::Rsync => "rsync",
63 Protocol::Http => "http",
64 Protocol::Https => "https",
65 Protocol::Ftp => "ftp",
66 }
67 )
68 }
69}