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 a single recent direct conversation in the user's history.
///
/// 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 RecentPrivateConversation {
    #[serde(skip_serializing_if = "Option::is_none")]
    max_message_id: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    user_ids: Option<Vec<u64>>,
}

impl RecentPrivateConversation {
    /// Creates a new [RecentPrivateConversation].
    pub const fn new() -> Self {
        Self {
            max_message_id: None,
            user_ids: None,
        }
    }
}

field_access! {
    RecentPrivateConversation {
        /// The highest message ID of the conversation, intended to support sorting the conversations by recency.
        max_message_id: option { u64 },
    }
}

field_access! {
    RecentPrivateConversation {
        /// The list of users other than the current user in the direct message conversation.
        ///
        /// This will be an empty list for direct messages sent to oneself.
        user_ids: option_cow_deref { [u64], Vec<u64> },
    }
}

impl_default!(RecentPrivateConversation);
impl_display!(RecentPrivateConversation);