playground_api/endpoints/versions.rs
1use serde::{Deserialize, Serialize};
2use std::borrow::Cow;
3
4/// A response containing Rust compiler toolchain versions for different release channels.
5///
6/// Includes versions for stable, beta, and nightly channels.
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8pub struct VersionsResponse<'a> {
9 /// The stable channel versions.
10 pub stable: ChannelVersion<'a>,
11 /// The beta channel versions.
12 pub beta: ChannelVersion<'a>,
13 /// The nightly channel versions.
14 pub nightly: ChannelVersion<'a>,
15}
16
17impl<'a> super::Response for VersionsResponse<'a> {}
18
19/// Tool versions for a specific Rust release channel.
20///
21/// Contains versions for rustc, rustfmt, clippy, and optionally miri.
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
23pub struct ChannelVersion<'a> {
24 /// Version information for `rustc`.
25 pub rustc: Version<'a>,
26 /// Version information for `rustfmt`.
27 pub rustfmt: Version<'a>,
28 /// Version information for `clippy`.
29 pub clippy: Version<'a>,
30 /// Optional version information for `miri`, if available.
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub miri: Option<Version<'a>>,
33}
34
35/// Version metadata for a specific tool in the Rust toolchain.
36///
37/// Includes the version string, commit hash, and release date.
38#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
39pub struct Version<'a> {
40 /// The version string (e.g., "1.70.0").
41 pub version: Cow<'a, str>,
42 /// The git commit hash of the release.
43 pub hash: Cow<'a, str>,
44 /// The release date (ISO 8601 format).
45 pub date: Cow<'a, str>,
46}