Skip to main content

zulip_api/message/
realm_playground.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details about a realm playground.
6///
7/// Modified from `openapi-generator-cli` output:
8///
9/// ```shell,no_build,no_run
10/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
11/// ```
12///
13/// ```text
14/// /*
15/// * Zulip REST API
16/// *
17/// * Powerful open source group chat
18/// *
19/// * The version of the OpenAPI document: 1.0.0
20/// *
21/// * Generated by: https://openapi-generator.tech
22/// */
23/// ```
24///
25/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
26///
27/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29pub struct RealmPlayground {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    id: Option<u64>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    name: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pygments_language: Option<String>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    url_template: Option<String>,
38}
39
40impl RealmPlayground {
41    /// Object containing details about a realm playground.
42    pub const fn new() -> Self {
43        Self {
44            id: None,
45            name: None,
46            pygments_language: None,
47            url_template: None,
48        }
49    }
50}
51
52field_access! {
53    RealmPlayground {
54        /// The unique ID for the realm playground.
55        id: option { u64 },
56    }
57}
58
59field_access! {
60    RealmPlayground {
61        /// The user-visible display name of the playground.
62        ///
63        /// Clients should display this in UI for picking which playground to open a code block in,
64        /// to differentiate between multiple configured playground options for a given pygments language.
65        ///
66        /// **Changes**: New in Zulip 4.0 (feature level 49).
67        name: option_cow_deref { str, String },
68        /// The name of the Pygments language lexer for that programming language.
69        pygments_language: option_cow_deref { str, String },
70        /// The [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.html) compliant URL template for the playground.
71        ///
72        /// The template contains exactly one variable named `code`, which determines how the extracted code should be substituted in the playground URL.
73        ///
74        /// **Changes**: New in Zulip 8.0 (feature level 196). This replaced the `url_prefix` parameter, which was used to construct URLs by just concatenating url_prefix and code.
75        url_template: option_cow_deref { str, String },
76    }
77}
78
79impl_default!(RealmPlayground);
80impl_display!(RealmPlayground);