playground_api/endpoints/
crates.rs

1use serde::{Deserialize, Serialize};
2use std::borrow::Cow;
3
4/// Represents metadata about a crate available on the Rust playground.
5///
6/// Includes the crate's name, version, and unique identifier.
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8pub struct CrateInformation<'a> {
9    /// The name of the crate.
10    pub name: Cow<'a, str>,
11    /// The version of the crate.
12    pub version: Cow<'a, str>,
13    /// The unique identifier for the crate.
14    pub id: Cow<'a, str>,
15}
16
17/// A response containing a list of available crates on the Rust playground.
18///
19/// Each crate is represented by a [`CrateInformation`] struct.
20#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
21pub struct CratesResponse<'a> {
22    /// A list of available crates.
23    pub crates: Vec<CrateInformation<'a>>,
24}
25
26impl<'a> super::Response for CratesResponse<'a> {}