Skip to main content

zulip_api/message/
muted_topic.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{impl_default, impl_display};
4
5/// Represents a muted topic.
6///
7/// - The first element of the tuple is the channel name in which the topic has to be muted
8/// - The second element is the topic name to be muted
9/// - The third element is an integer UNIX timestamp representing when the topic was muted
10///
11/// **Changes**: Deprecated in Zulip 6.0 (feature level 134). Starting with this version, `muted_topics` will only be present in the response if the `user_topic` object, which generalizes and replaces this field, is not explicitly requested via `fetch_event_types`.  Before Zulip 3.0 (feature level 1), the `muted_topics` array objects were 2-item tuples and did not include the timestamp information for when the topic was muted.
12///
13/// Modified from `openapi-generator-cli` output:
14///
15/// ```shell,no_build,no_run
16/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
17/// ```
18///
19/// ```text
20/// /*
21/// * Zulip REST API
22/// *
23/// * Powerful open source group chat
24/// *
25/// * The version of the OpenAPI document: 1.0.0
26/// *
27/// * Generated by: https://openapi-generator.tech
28/// */
29/// ```
30///
31/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
32///
33/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
34#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
35pub struct MutedTopic(String, String, u64);
36
37impl MutedTopic {
38    /// Creates a new [MutedTopic].
39    pub const fn new() -> Self {
40        Self(String::new(), String::new(), 0)
41    }
42
43    /// Gets the channel name.
44    pub fn channel_name(&self) -> &str {
45        self.0.as_str()
46    }
47
48    /// Sets the channel name.
49    pub fn set_channel_name(&mut self, val: String) {
50        self.0 = val;
51    }
52
53    /// Builder function that sets the channel name.
54    pub fn with_channel_name(self, val: String) -> Self {
55        Self(val, self.1, self.2)
56    }
57
58    /// Gets the topic name.
59    pub fn topic_name(&self) -> &str {
60        self.1.as_str()
61    }
62
63    /// Sets the topic name.
64    pub fn set_topic_name(&mut self, val: String) {
65        self.1 = val;
66    }
67
68    /// Builder function that sets the topic name.
69    pub fn with_topic_name(self, val: String) -> Self {
70        Self(self.0, val, self.2)
71    }
72
73    /// Gets the timestamp.
74    pub const fn timestamp(&self) -> u64 {
75        self.2
76    }
77
78    /// Sets the timestamp.
79    pub fn set_timestamp(&mut self, val: u64) {
80        self.2 = val;
81    }
82
83    /// Builder function that sets the timestamp.
84    pub fn with_timestamp(self, val: u64) -> Self {
85        Self(self.0, self.1, val)
86    }
87}
88
89impl_default!(MutedTopic);
90impl_display!(MutedTopic);