zulip_api/message/user_status.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display, ReactionType};
4
5/// Represents the status details of a user with the key of the object being the ID of the user.
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 UserStatus {
30 #[serde(skip_serializing_if = "Option::is_none")]
31 away: Option<bool>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 status_text: Option<String>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 emoji_name: Option<String>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 emoji_code: Option<String>,
38 #[serde(skip_serializing_if = "Option::is_none")]
39 reaction_type: Option<ReactionType>,
40}
41
42impl UserStatus {
43 /// Creates a new [UserStatus].
44 pub const fn new() -> Self {
45 Self {
46 away: None,
47 status_text: None,
48 emoji_name: None,
49 emoji_code: None,
50 reaction_type: None,
51 }
52 }
53}
54
55field_access! {
56 UserStatus {
57 /// If present, the user has marked themself \"away\".
58 ///
59 /// **Changes**: Deprecated in Zulip 6.0 (feature level 148);
60 /// starting with that feature level,
61 /// `away` is a legacy way to access the user's `presence_enabled` setting,
62 /// with `away = !presence_enabled`.
63 ///
64 /// To be removed in a future release.
65 away: option { bool },
66 /// If present, a string indicating the type of emoji.
67 reaction_type: option { ReactionType },
68 }
69}
70
71field_access! {
72 UserStatus {
73 /// If present, the text content of the user's status message.
74 status_text: option_cow_deref { str, String },
75 /// If present, the name for the emoji to associate with the user's status. **Changes**: New in Zulip 5.0 (feature level 86).
76 emoji_name: option_cow_deref { str, String },
77 /// If present, a unique identifier, defining the specific emoji codepoint requested, within the namespace of the `reaction_type`.
78 ///
79 /// **Changes**: New in Zulip 5.0 (feature level 86).
80 emoji_code: option_cow_deref { str, String },
81 }
82}
83
84impl_default!(UserStatus);
85impl_display!(UserStatus);