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 whether named topics and the empty topic are enabled in a channel.
///
/// - `\"inherit\"`: Messages can be sent to named topics in this channel, and the organization-level `realm_topics_policy` is used for whether messages can be sent to the empty topic in this   channel.
/// - `\"allow_empty_topic\"`: Messages can be sent to both named topics and the empty topic in this channel.
/// - `\"disable_empty_topic\"`: Messages can be sent to named topics in this channel, but the empty topic is disabled.
/// - `\"empty_topic_only\"`: Messages can be sent to the empty topic in this channel, but named topics are disabled.
///
/// The `\"empty_topic_only\"` policy can only be set if all existing messages in the channel are already in the empty topic.  When creating a new channel, if the `topics_policy` is not specified, the `\"inherit\"` option will be set.
///
/// **Changes**: In Zulip 11.0 (feature level 404), the `\"empty_topic_only\"` option was added.  New in Zulip 11.0 (feature level 392).  [realm-topics-policy]: /help/require-topics#set-the-default-general-chat-topic-configuration
///
/// 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, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TopicsPolicy {
    Inherit,
    AllowEmptyTopic,
    DisableEmptyTopic,
    EmptyTopicOnly,
}

impl TopicsPolicy {
    /// Creates a new [TopicsPolicy].
    pub const fn new() -> Self {
        Self::Inherit
    }

    /// Gets the [TopicsPolicy] string representation.
    pub const fn as_str(&self) -> &'static str {
        match self {
            Self::Inherit => "inherit",
            Self::AllowEmptyTopic => "allow_empty_topic",
            Self::DisableEmptyTopic => "disable_empty_topic",
            Self::EmptyTopicOnly => "empty_topic_only",
        }
    }
}

impl_default!(TopicsPolicy);
impl_display!(TopicsPolicy);