zulip-api 0.0.8

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

use crate::{field_access, impl_default, impl_display, VisibilityPolicy};

/// Represents the user's configuration for a given topic.
///
/// 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 UserTopic {
    #[serde(skip_serializing_if = "Option::is_none")]
    stream_id: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    topic_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    last_updated: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    visibility_policy: Option<VisibilityPolicy>,
}

impl UserTopic {
    /// Creates a new [UserTopic].
    pub const fn new() -> UserTopic {
        UserTopic {
            stream_id: None,
            topic_name: None,
            last_updated: None,
            visibility_policy: None,
        }
    }
}

field_access! {
    UserTopic {
        /// The ID of the channel to which the topic belongs.
        stream_id: option { u64 },
        /// An integer UNIX timestamp representing when the user-topic relationship was changed.
        last_updated: option { u64 },
        /// An integer indicating the user's visibility configuration for the topic.
        visibility_policy: option { VisibilityPolicy },
    }
}

field_access! {
    UserTopic {
        /// The name of the topic.
        ///
        /// Note that the empty string topic may have been rewritten by the server to the value of `realm_empty_topic_display_name` found in the
        /// [`POST /register`](https://zulip.com/api/register-queue) response depending on the value of the `empty_topic_name`
        /// [client capability](https://zulip.com/api/register-queue#parameter-client_capabilities).
        ///
        /// **Changes**: The `empty_topic_name` client capability is new in Zulip 10.0 (feature level 334).
        topic_name: option_cow_deref { str, String },
    }
}

impl_default!(UserTopic);
impl_display!(UserTopic);