Skip to main content

zulip_api/message/
recent_private_conversation.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents a single recent direct conversation in the user's history.
6///
7/// Modified from `openapi-generator-cli` output:
8///
9/// ```shell,no_build,no_run
10/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
11/// ```
12///
13/// ```text
14/// /*
15/// * Zulip REST API
16/// *
17/// * Powerful open source group chat
18/// *
19/// * The version of the OpenAPI document: 1.0.0
20/// *
21/// * Generated by: https://openapi-generator.tech
22/// */
23/// ```
24///
25/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
26///
27/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29pub struct RecentPrivateConversation {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    max_message_id: Option<u64>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    user_ids: Option<Vec<u64>>,
34}
35
36impl RecentPrivateConversation {
37    /// Creates a new [RecentPrivateConversation].
38    pub const fn new() -> Self {
39        Self {
40            max_message_id: None,
41            user_ids: None,
42        }
43    }
44}
45
46field_access! {
47    RecentPrivateConversation {
48        /// The highest message ID of the conversation, intended to support sorting the conversations by recency.
49        max_message_id: option { u64 },
50    }
51}
52
53field_access! {
54    RecentPrivateConversation {
55        /// The list of users other than the current user in the direct message conversation.
56        ///
57        /// This will be an empty list for direct messages sent to oneself.
58        user_ids: option_cow_deref { [u64], Vec<u64> },
59    }
60}
61
62impl_default!(RecentPrivateConversation);
63impl_display!(RecentPrivateConversation);