playground_api/endpoints/
gist.rs

1use serde::{Deserialize, Serialize};
2
3/// A request to create a new Gist on the Rust playground.
4///
5/// Contains the code snippet to be shared.
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
7pub struct GistCreateRequest {
8    /// The Rust code to include in the Gist.
9    pub code: String,
10}
11
12impl GistCreateRequest {
13    /// Creates a new [`GistCreateRequest`] with the given code.
14    ///
15    /// # Arguments
16    ///
17    /// * `code` - The Rust code to be included in the Gist.
18    ///
19    /// # Returns
20    ///
21    /// A new [`GistCreateRequest`] containing the provided code.
22    pub fn new(code: String) -> Self {
23        Self { code }
24    }
25}
26
27/// A response returned after creating or retrieving a Gist.
28///
29/// Contains the Gist's unique ID, URL, and the stored code.
30#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
31pub struct GistResponse {
32    /// The unique identifier of the Gist.
33    pub id: String,
34    /// The public URL of the Gist.
35    pub url: String,
36    /// The Rust code stored in the Gist.
37    pub code: String,
38}