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
27impl super::Request for GistCreateRequest {
28 fn endpoint<'a>(&self) -> super::Endpoints<'a> {
29 super::Endpoints::GistCreate
30 }
31}
32
33/// A response returned after creating or retrieving a Gist.
34///
35/// Contains the Gist's unique ID, URL, and the stored code.
36#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
37pub struct GistResponse {
38 /// The unique identifier of the Gist.
39 pub id: String,
40 /// The public URL of the Gist.
41 pub url: String,
42 /// The Rust code stored in the Gist.
43 pub code: String,
44}
45
46impl super::Response for GistResponse {}