playground_api/endpoints/
common.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents the Rust edition to use.
4///
5/// Each edition introduces new language features and idioms while maintaining compatibility.
6#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
7#[cfg_attr(feature = "poise-bot", derive(poise::ChoiceParameter))]
8pub enum Edition {
9    /// Rust 2024 Edition
10    #[cfg_attr(feature = "poise-bot", name = "Edition 2024")]
11    #[serde(rename = "2024")]
12    Edition2024,
13
14    /// Rust 2021 Edition
15    #[cfg_attr(feature = "poise-bot", name = "Edition 2021")]
16    #[serde(rename = "2021")]
17    Edition2021,
18
19    /// Rust 2018 Edition
20    #[cfg_attr(feature = "poise-bot", name = "Edition 2018")]
21    #[serde(rename = "2018")]
22    Edition2018,
23
24    /// Rust 2015 Edition
25    #[cfg_attr(feature = "poise-bot", name = "Edition 2015")]
26    #[serde(rename = "2015")]
27    Edition2015,
28}
29
30/// Defines the type of crate to be compiled: binary or library.
31#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
32#[cfg_attr(feature = "poise-bot", derive(poise::ChoiceParameter))]
33pub enum CrateType {
34    /// A binary crate with a `main` function, compiled to an executable.
35    #[serde(rename = "bin")]
36    Binary,
37
38    /// A library crate, with a specified library type.
39    #[serde(rename = "lib")]
40    Library,
41}
42
43/// Indicates whether to compile code in debug or release mode.
44#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
45#[cfg_attr(feature = "poise-bot", derive(poise::ChoiceParameter))]
46#[serde(rename_all = "lowercase")]
47pub enum Mode {
48    /// Compile with debug information and no optimizations.
49    Debug,
50
51    /// Compile with optimizations for performance.
52    Release,
53}
54
55/// Specifies the Rust release channel to use.
56#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
57#[cfg_attr(feature = "poise-bot", derive(poise::ChoiceParameter))]
58#[serde(rename_all = "lowercase")]
59pub enum Channel {
60    /// Stable channel – tested and officially released features.
61    Stable,
62
63    /// Beta channel – pre-release testing for the next stable release.
64    Beta,
65
66    /// Nightly channel – bleeding-edge features and experimental tools.
67    Nightly,
68}