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};

/// Represents details of all unread messages of a single subscribed channel.
///
/// This includes muted channels and muted topics, even though those messages are excluded from `count`.  **Changes**: Prior to Zulip 5.0 (feature level 90), these objects included a `sender_ids` property, which listed the set of IDs of users who had sent the unread messages.
///
/// 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 UnreadMsgsStream {
    #[serde(skip_serializing_if = "Option::is_none")]
    topic: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    stream_id: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    unread_message_ids: Option<Vec<i32>>,
}

impl UnreadMsgsStream {
    /// Creates a new [UnreadMsgsStream].
    pub const fn new() -> Self {
        Self {
            topic: None,
            stream_id: None,
            unread_message_ids: None,
        }
    }
}

field_access! {
    UnreadMsgsStream {
        /// The topic under which the messages were sent.
        ///
        /// 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: option_cow_deref { str, String },
        /// The message IDs of the recent unread messages sent in this channel, sorted in ascending order.
        unread_message_ids: option_cow_deref { [i32], Vec<i32> },
    }
}

field_access! {
    UnreadMsgsStream {
        /// The ID of the channel to which the messages were sent.
        stream_id: option { i32 },
    }
}

impl_default!(UnreadMsgsStream);
impl_display!(UnreadMsgsStream);