playground-api 0.5.1

Simple API-binding for The Rust Playground
Documentation
use serde::{Deserialize, Serialize};
use std::borrow::Cow;

/// A response containing Rust compiler toolchain versions for different release channels.
///
/// Includes versions for stable, beta, and nightly channels.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct VersionsResponse<'a> {
    /// The stable channel versions.
    pub stable: ChannelVersion<'a>,
    /// The beta channel versions.
    pub beta: ChannelVersion<'a>,
    /// The nightly channel versions.
    pub nightly: ChannelVersion<'a>,
}

impl<'a> super::Response for VersionsResponse<'a> {}

/// Tool versions for a specific Rust release channel.
///
/// Contains versions for rustc, rustfmt, clippy, and optionally miri.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ChannelVersion<'a> {
    /// Version information for `rustc`.
    pub rustc: Version<'a>,
    /// Version information for `rustfmt`.
    pub rustfmt: Version<'a>,
    /// Version information for `clippy`.
    pub clippy: Version<'a>,
    /// Optional version information for `miri`, if available.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub miri: Option<Version<'a>>,
}

/// Version metadata for a specific tool in the Rust toolchain.
///
/// Includes the version string, commit hash, and release date.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Version<'a> {
    /// The version string (e.g., "1.70.0").
    pub version: Cow<'a, str>,
    /// The git commit hash of the release.
    pub hash: Cow<'a, str>,
    /// The release date (ISO 8601 format).
    pub date: Cow<'a, str>,
}