Skip to main content

zulip_api/message/
realm_linkifier.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents the realm linkifier list item.
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 RealmLinkifier {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pattern: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    url_template: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    id: Option<u64>,
36}
37
38impl RealmLinkifier {
39    /// Creates a new [RealmLinkifier].
40    pub const fn new() -> Self {
41        Self {
42            pattern: None,
43            url_template: None,
44            id: None,
45        }
46    }
47}
48
49field_access! {
50    RealmLinkifier {
51        /// The [Python regular expression](https://docs.python.org/3/howto/regex.html) pattern which represents the pattern that should be linkified on matching.
52        pattern: option_cow_deref { str, String },
53        /// The [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.html) compliant URL template with which the pattern matching string should be linkified.
54        ///
55        /// **Changes**: New in Zulip 7.0 (feature level 176). This replaced `url_format`, which contained a URL format string.
56        url_template: option_cow_deref { str, String },
57    }
58}
59
60field_access! {
61    RealmLinkifier {
62        /// The ID of the linkifier.
63        id: option { u64 },
64    }
65}
66
67impl_default!(RealmLinkifier);
68impl_display!(RealmLinkifier);