1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use serde::{Deserialize, Serialize};
use crate::{impl_default, impl_display};
/// Represents a legacy property for [linkifiers](crate::RealmLinkifier).
///
/// Present if `realm_filters` is present in `fetch_event_types`.
///
/// When present, this is always an empty array.
///
/// **Changes**: Prior to Zulip 7.0 (feature level 176), this was
/// an array of tuples, where each tuple described a linkifier. The first
/// element of the tuple was a string regex pattern which represented the
/// pattern to be linkified on matching, for example `"#(?P<id>[123])"`.
/// The second element was a URL format string that the pattern should be
/// linkified with. A URL format string for the above example would be
/// `"https://realm.com/my_realm_filter/%(id)s"`. And the third element
/// was the ID of the realm filter.
///
/// **Deprecated** in Zulip 4.0 (feature level 54), replaced by the
/// `realm_linkifiers` key.
///
/// Modified from `openapi-generator-cli` output:
///
/// ```shell,no_build,no_run
/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
/// ```
///
/// ```text
/// /*
/// * Zulip REST API
/// *
/// * Powerful open source group chat
/// *
/// * The version of the OpenAPI document: 1.0.0
/// *
/// * Generated by: https://openapi-generator.tech
/// */
/// ```
///
/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
///
/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RealmFilter(String, String, u64);
impl RealmFilter {
/// Creates a new [RealmFilter].
pub const fn new() -> Self {
Self(String::new(), String::new(), 0)
}
/// Gets the regex pattern which represented the pattern to be linkified on matching, for example `"#(?P<id>[123])"`.
pub fn linkified_regex(&self) -> &str {
self.0.as_str()
}
/// Sets the regex pattern which represented the pattern to be linkified on matching, for example `"#(?P<id>[123])"`.
pub fn set_linkified_regex(&mut self, val: String) {
self.0 = val;
}
/// Builder function that sets the regex pattern which represented the pattern to be linkified on matching, for example `"#(?P<id>[123])"`.
pub fn with_linkified_regex(self, val: String) -> Self {
Self(val, self.1, self.2)
}
/// Gets the URL format string that the pattern should be linkified with.
///
/// A URL format string for the above example would be `"https://realm.com/my_realm_filter/%(id)s"`.
pub fn url_format(&self) -> &str {
self.1.as_str()
}
/// Sets the URL format string that the pattern should be linkified with.
///
/// A URL format string for the above example would be `"https://realm.com/my_realm_filter/%(id)s"`.
pub fn set_url_format(&mut self, val: String) {
self.1 = val;
}
/// Builder function that sets the URL format string that the pattern should be linkified with.
///
/// A URL format string for the above example would be `"https://realm.com/my_realm_filter/%(id)s"`.
pub fn with_url_format(self, val: String) -> Self {
Self(self.0, val, self.2)
}
/// Gets the realm filter ID.
pub const fn id(&self) -> u64 {
self.2
}
/// Sets the realm filter ID.
pub fn set_id(&mut self, val: u64) {
self.2 = val;
}
/// Builder function that sets the realm filter ID.
pub fn with_id(self, val: u64) -> Self {
Self(self.0, self.1, val)
}
}
impl_default!(RealmFilter);
impl_display!(RealmFilter);