Skip to main content

zulip_api/message/
realm_domain.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details of the newly added domain.
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 RealmDomain {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    domain: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    allow_subdomains: Option<bool>,
34}
35
36impl RealmDomain {
37    /// Creates a new [RealmDomain].
38    pub const fn new() -> Self {
39        Self {
40            domain: None,
41            allow_subdomains: None,
42        }
43    }
44}
45
46field_access! {
47    RealmDomain {
48        /// The new allowed domain.
49        domain: option_cow_deref { str, String },
50    }
51}
52
53field_access! {
54    RealmDomain {
55        /// Whether subdomains are allowed for this domain.
56        allow_subdomains: option { bool },
57    }
58}
59
60impl_default!(RealmDomain);
61impl_display!(RealmDomain);