acme_types/v2/
directory.rs

1#[cfg(feature = "json")]
2use serde::{Deserialize, Serialize};
3
4/// Defines an ACME directory resource.
5///
6/// For more information, refer to [RFC 8555 § 7.1.1](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1)
7#[derive(Clone, Debug)]
8#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
9pub struct Directory {
10    /// New nonce URL
11    #[cfg_attr(feature = "json", serde(rename = "newNonce"))]
12    pub new_nonce: String,
13    /// New account URL
14    #[cfg_attr(feature = "json", serde(rename = "newAccount"))]
15    pub new_account: String,
16    /// New order URL
17    #[cfg_attr(feature = "json", serde(rename = "newOrder"))]
18    pub new_order: String,
19    /// New authorization URL
20    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
21    #[cfg_attr(feature = "json", serde(rename = "newAuthz"))]
22    pub new_authorization: Option<String>,
23    /// Revoke certificate URL
24    #[cfg_attr(feature = "json", serde(rename = "revokeCert"))]
25    pub revoke_certificate: String,
26    /// Key change URL
27    #[cfg_attr(feature = "json", serde(rename = "keyChange"))]
28    pub key_change: String,
29    /// Metadata object
30    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
31    #[cfg_attr(feature = "json", serde(rename = "meta"))]
32    pub metadata: Option<DirectoryMetadata>,
33}
34
35#[cfg(feature = "json")]
36impl Directory {
37    /// Deserializes a Directory object from a JSON str
38    pub fn from_str(s: &str) -> Result<Directory, serde_json::error::Error> {
39        serde_json::from_str(s)
40    }
41
42    /// Serializes a Directory object to a JSON String
43    pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
44        serde_json::to_string(self)
45    }
46}
47
48/// Defines an ACME directory metadata object.
49///
50/// For more information, refer to [RFC 8555 § 7.1.1](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1)
51#[derive(Clone, Debug)]
52#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
53pub struct DirectoryMetadata {
54    /// ACME provider Terms of Service URL
55    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
56    #[cfg_attr(feature = "json", serde(rename = "termsOfService"))]
57    pub terms_of_service: Option<String>,
58    /// ACME provider website URL
59    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
60    pub website: Option<String>,
61    /// Array of hostnames recognized for the purpose of CAA record validation
62    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
63    #[cfg_attr(feature = "json", serde(rename = "caaIdentities"))]
64    pub caa_identities: Option<Vec<String>>,
65    /// Whether or not an external account is required for account registration by the ACME provider
66    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
67    #[cfg_attr(feature = "json", serde(rename = "externalAccountRequired"))]
68    pub external_account_required: Option<bool>,
69}