zulip_api/message/unread_msgs/stream.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details of all unread messages of a single subscribed channel.
6///
7/// 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.
8///
9/// Modified from `openapi-generator-cli` output:
10///
11/// ```shell,no_build,no_run
12/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
13/// ```
14///
15/// ```text
16/// /*
17/// * Zulip REST API
18/// *
19/// * Powerful open source group chat
20/// *
21/// * The version of the OpenAPI document: 1.0.0
22/// *
23/// * Generated by: https://openapi-generator.tech
24/// */
25/// ```
26///
27/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
28///
29/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
30#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
31pub struct UnreadMsgsStream {
32 #[serde(skip_serializing_if = "Option::is_none")]
33 topic: Option<String>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 stream_id: Option<i32>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 unread_message_ids: Option<Vec<i32>>,
38}
39
40impl UnreadMsgsStream {
41 /// Creates a new [UnreadMsgsStream].
42 pub const fn new() -> Self {
43 Self {
44 topic: None,
45 stream_id: None,
46 unread_message_ids: None,
47 }
48 }
49}
50
51field_access! {
52 UnreadMsgsStream {
53 /// The topic under which the messages were sent.
54 ///
55 /// 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
56 /// [`POST /register`](https://zulip.com/api/register-queue) response depending on the value of the `empty_topic_name`
57 /// [client capability](https://zulip.com/api/register-queue#parameter-client_capabilities).
58 ///
59 /// **Changes**: The `empty_topic_name` client capability is new in Zulip 10.0 (feature level 334).
60 topic: option_cow_deref { str, String },
61 /// The message IDs of the recent unread messages sent in this channel, sorted in ascending order.
62 unread_message_ids: option_cow_deref { [i32], Vec<i32> },
63 }
64}
65
66field_access! {
67 UnreadMsgsStream {
68 /// The ID of the channel to which the messages were sent.
69 stream_id: option { i32 },
70 }
71}
72
73impl_default!(UnreadMsgsStream);
74impl_display!(UnreadMsgsStream);