Skip to main content

zulip_api/message/
server_thumbnail_format.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details of the server thumbnail image format.
6///
7/// Any image with a source starting with `/user_uploads/thumbnail/` can have its last path component replaced with any of the names contained in this list, to obtain the desired thumbnail size.  **Changes**: New in Zulip 9.0 (feature level 273). #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
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 ServerThumbnailFormat {
32    #[serde(skip_serializing_if = "Option::is_none")]
33    name: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    max_width: Option<u64>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    max_height: Option<u64>,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    format: Option<String>,
40    #[serde(skip_serializing_if = "Option::is_none")]
41    animated: Option<bool>,
42}
43
44impl ServerThumbnailFormat {
45    /// Creates a new [ServerThumbnailFormat].
46    pub const fn new() -> Self {
47        Self {
48            name: None,
49            max_width: None,
50            max_height: None,
51            format: None,
52            animated: None,
53        }
54    }
55}
56
57field_access! {
58    ServerThumbnailFormat {
59        /// The file path component of the thumbnail format.
60        name: option_cow_deref { str, String },
61        /// The extension of this format.
62        format: option_cow_deref { str, String },
63    }
64}
65
66field_access! {
67    ServerThumbnailFormat {
68        /// The maximum width of this format.
69        max_width: option { u64 },
70        /// The maximum height of this format.
71        max_height: option { u64 },
72        /// If this file format is animated.
73        ///
74        /// These formats are only generated for uploaded imates which themselves are animated.
75        animated: option { bool },
76    }
77}
78
79impl_default!(ServerThumbnailFormat);
80impl_display!(ServerThumbnailFormat);