chrome_for_testing/api/
mod.rs

1use crate::api::version::Version;
2use platform::Platform;
3use reqwest::Url;
4use serde::Deserialize;
5use std::sync::LazyLock;
6
7/// Chrome release channel definitions.
8pub mod channel;
9
10/// Platform identification for different operating systems and architectures.
11pub mod platform;
12
13/// Version parsing and representation.
14pub mod version;
15
16/// API request for a list of working releases. None are assigned to any channel.
17pub mod known_good_versions;
18
19/// The last working releases for each channel.
20pub mod last_known_good_versions;
21
22/// The standard chrome-for-testing API endpoint protocol and hostname.
23///
24/// Consult <https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints>
25/// for verification.
26pub static API_BASE_URL: LazyLock<Url> =
27    LazyLock::new(|| Url::parse("https://googlechromelabs.github.io").expect("Valid URL"));
28
29/// Represents a download link for a specific platform.
30#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
31pub struct Download {
32    /// The target platform for this download.
33    pub platform: Platform,
34
35    /// The download URL.
36    pub url: String,
37}
38
39/// Trait for types that contain a version identifier.
40pub trait HasVersion {
41    /// Returns the version identifier.
42    fn version(&self) -> Version;
43}
44
45impl HasVersion for known_good_versions::VersionWithoutChannel {
46    fn version(&self) -> Version {
47        self.version
48    }
49}
50
51impl HasVersion for last_known_good_versions::VersionInChannel {
52    fn version(&self) -> Version {
53        self.version
54    }
55}