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 details of the server thumbnail image format.
///
/// 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)]
///
/// 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 ServerThumbnailFormat {
    #[serde(skip_serializing_if = "Option::is_none")]
    name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    max_width: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    max_height: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    format: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    animated: Option<bool>,
}

impl ServerThumbnailFormat {
    /// Creates a new [ServerThumbnailFormat].
    pub const fn new() -> Self {
        Self {
            name: None,
            max_width: None,
            max_height: None,
            format: None,
            animated: None,
        }
    }
}

field_access! {
    ServerThumbnailFormat {
        /// The file path component of the thumbnail format.
        name: option_cow_deref { str, String },
        /// The extension of this format.
        format: option_cow_deref { str, String },
    }
}

field_access! {
    ServerThumbnailFormat {
        /// The maximum width of this format.
        max_width: option { u64 },
        /// The maximum height of this format.
        max_height: option { u64 },
        /// If this file format is animated.
        ///
        /// These formats are only generated for uploaded imates which themselves are animated.
        animated: option { bool },
    }
}

impl_default!(ServerThumbnailFormat);
impl_display!(ServerThumbnailFormat);