chrome_for_testing/api/
mod.rs1use crate::api::version::Version;
2use platform::Platform;
3use reqwest::Url;
4use serde::{Deserialize, Serialize};
5use std::sync::LazyLock;
6
7pub mod channel;
9
10pub mod platform;
12
13pub mod version;
15
16pub mod known_good_versions;
18
19pub mod last_known_good_versions;
21
22pub static API_BASE_URL: LazyLock<Url> =
27 LazyLock::new(|| Url::parse("https://googlechromelabs.github.io").expect("Valid URL"));
28
29#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
31pub struct Download {
32 pub platform: Platform,
34
35 pub url: String,
37}
38
39pub trait DownloadsByPlatform {
41 fn for_platform(&self, platform: Platform) -> Option<&Download>;
43}
44
45impl DownloadsByPlatform for [Download] {
46 fn for_platform(&self, platform: Platform) -> Option<&Download> {
47 self.iter().find(|d| d.platform == platform)
48 }
49}
50
51pub trait HasVersion {
53 fn version(&self) -> Version;
55}
56
57impl HasVersion for known_good_versions::VersionWithoutChannel {
58 fn version(&self) -> Version {
59 self.version
60 }
61}
62
63impl HasVersion for last_known_good_versions::VersionInChannel {
64 fn version(&self) -> Version {
65 self.version
66 }
67}