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 the realm linkifier list item.
///
/// 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 RealmLinkifier {
    #[serde(skip_serializing_if = "Option::is_none")]
    pattern: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    url_template: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    id: Option<u64>,
}

impl RealmLinkifier {
    /// Creates a new [RealmLinkifier].
    pub const fn new() -> Self {
        Self {
            pattern: None,
            url_template: None,
            id: None,
        }
    }
}

field_access! {
    RealmLinkifier {
        /// The [Python regular expression](https://docs.python.org/3/howto/regex.html) pattern which represents the pattern that should be linkified on matching.
        pattern: option_cow_deref { str, String },
        /// The [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.html) compliant URL template with which the pattern matching string should be linkified.
        ///
        /// **Changes**: New in Zulip 7.0 (feature level 176). This replaced `url_format`, which contained a URL format string.
        url_template: option_cow_deref { str, String },
    }
}

field_access! {
    RealmLinkifier {
        /// The ID of the linkifier.
        id: option { u64 },
    }
}

impl_default!(RealmLinkifier);
impl_display!(RealmLinkifier);