Skip to main content

chrome_for_testing/
lib.rs

1//! # Chrome for Testing API Client
2//!
3//! This crate provides programmatic access to "chrome-for-testing" JSON APIs,
4//! which are used to retrieve version details and download URLs for `Chrome`, `ChromeDriver`, and
5//! Chrome Headless Shell for testing purposes.
6//!
7//! ## Modules Overview
8//!
9//! - [`chromedriver`]: `ChromeDriver` specific utilities, such as log level configuration.
10//!
11//! ## API Endpoints
12//!
13//! The crate leverages the following JSON API endpoints:
14//!
15//! - **Last Known Good Versions**:
16//!   Recent good versions for each release channel (Stable/Beta/Dev/Canary), including `chrome`,
17//!   `chromedriver`, and `chrome-headless-shell` downloads. Perfect if you just need the "latest
18//!   stable" version for example.
19//!
20//! - **Known Good Versions**:
21//!   All known good versions. Longer API response, not pre-grouped per release channel. Good fit
22//!   if you have a hardcoded old version that you want to resolve a download URL for. Older
23//!   entries may omit `chromedriver` and `chrome-headless-shell` downloads.
24//!
25//! For detailed documentation on these APIs, see the
26//! [official Chrome for Testing documentation](https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints).
27//!
28//! ## Features
29//!
30//! - **Ease of Use**: Simplifies interaction with Chrome's testing-related APIs.
31//! - **Type-Safe Deserialization**: Automatically maps JSON responses to Rust structs for
32//!   seamless API interaction.
33//! - **Asynchronous Support**: Fully asynchronous.
34//!
35//! ## Example Usage
36//!
37//! ```rust,no_run
38//! #[tokio::main]
39//! async fn main() {
40//!     use chrome_for_testing::KnownGoodVersions;
41//!
42//!     let client = reqwest::Client::new();
43//!     match KnownGoodVersions::fetch(&client).await {
44//!         Ok(data) => println!("Successfully fetched Chrome versions: {data:?}"),
45//!         Err(e) => println!("Error occurred: {e:?}"),
46//!     }
47//! }
48//! ```
49
50/// `ChromeDriver` specific utilities, such as log level configuration.
51pub mod chromedriver;
52
53pub(crate) mod api;
54pub(crate) mod error;
55
56pub use api::Download;
57pub use api::DownloadsByPlatform;
58pub use api::HasVersion;
59pub use api::channel::Channel;
60pub use api::channel::ParseChannelError;
61pub use api::known_good_versions::Downloads as KnownGoodDownloads;
62pub use api::known_good_versions::KnownGoodVersions;
63pub use api::known_good_versions::VersionWithoutChannel;
64pub use api::last_known_good_versions::Downloads as LastKnownGoodDownloads;
65pub use api::last_known_good_versions::LastKnownGoodVersions;
66pub use api::last_known_good_versions::VersionInChannel;
67pub use api::platform::ParsePlatformError;
68pub use api::platform::Platform;
69pub use api::version::ParseVersionError;
70pub use api::version::Version;
71pub use error::Error;
72
73/// Result type returned by fallible crate APIs.
74pub type Result<T, E = Error> = std::result::Result<T, rootcause::Report<E>>;