winget_types/locale/
agreement.rs

1use alloc::string::String;
2
3use url::Url;
4
5#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
8pub struct Agreement {
9    /// The label for a package agreement.
10    #[cfg_attr(
11        feature = "serde",
12        serde(rename = "AgreementLabel", skip_serializing_if = "Option::is_none")
13    )]
14    pub label: Option<String>,
15
16    /// The text or body of a package agreement.
17    #[cfg_attr(
18        feature = "serde",
19        serde(rename = "Agreement", skip_serializing_if = "Option::is_none")
20    )]
21    pub text: Option<String>,
22
23    /// The URL for a package agreement.
24    #[cfg_attr(
25        feature = "serde",
26        serde(rename = "AgreementUrl", skip_serializing_if = "Option::is_none")
27    )]
28    pub url: Option<Url>,
29}
30
31impl Agreement {
32    /// Returns `true` if all the `Agreement` fields are `None`.
33    ///
34    /// # Examples
35    /// ```
36    /// use winget_types::locale::Agreement;
37    ///
38    /// let mut agreement = Agreement::default();
39    /// assert!(agreement.is_empty());
40    ///
41    /// agreement.label = Some("An agreement".into());
42    /// assert!(!agreement.is_empty());
43    /// ```
44    #[must_use]
45    pub const fn is_empty(&self) -> bool {
46        self.label.is_none() && self.text.is_none() && self.url.is_none()
47    }
48}