zulip-api 0.0.8

Client library for interacting with the Zulip API
Documentation
use serde::{Deserialize, Serialize};

use crate::{impl_default, impl_display};

/// Represents a muted topic.
///
/// - The first element of the tuple is the channel name in which the topic has to be muted
/// - The second element is the topic name to be muted
/// - The third element is an integer UNIX timestamp representing when the topic was muted
///
/// **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.
///
/// 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, Eq, PartialEq, Deserialize, Serialize)]
pub struct MutedTopic(String, String, u64);

impl MutedTopic {
    /// Creates a new [MutedTopic].
    pub const fn new() -> Self {
        Self(String::new(), String::new(), 0)
    }

    /// Gets the channel name.
    pub fn channel_name(&self) -> &str {
        self.0.as_str()
    }

    /// Sets the channel name.
    pub fn set_channel_name(&mut self, val: String) {
        self.0 = val;
    }

    /// Builder function that sets the channel name.
    pub fn with_channel_name(self, val: String) -> Self {
        Self(val, self.1, self.2)
    }

    /// Gets the topic name.
    pub fn topic_name(&self) -> &str {
        self.1.as_str()
    }

    /// Sets the topic name.
    pub fn set_topic_name(&mut self, val: String) {
        self.1 = val;
    }

    /// Builder function that sets the topic name.
    pub fn with_topic_name(self, val: String) -> Self {
        Self(self.0, val, self.2)
    }

    /// Gets the timestamp.
    pub const fn timestamp(&self) -> u64 {
        self.2
    }

    /// Sets the timestamp.
    pub fn set_timestamp(&mut self, val: u64) {
        self.2 = val;
    }

    /// Builder function that sets the timestamp.
    pub fn with_timestamp(self, val: u64) -> Self {
        Self(self.0, self.1, val)
    }
}

impl_default!(MutedTopic);
impl_display!(MutedTopic);