From be0a3e27dd0b4d14b2fc7977dd5f90fddb0f257c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Tue, 24 Dec 2024 11:14:37 +0100 Subject: [PATCH] Adjust visibility --- src/config.rs | 14 ++++----- src/config/account.rs | 22 ++++++------- src/config/certificate.rs | 66 +++++++++++++++++++-------------------- src/config/endpoint.rs | 16 +++++----- src/config/global.rs | 30 +++++++++--------- src/config/hook.rs | 22 ++++++------- src/config/rate_limit.rs | 6 ++-- 7 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/config.rs b/src/config.rs index 39761f4..2219371 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,19 +23,19 @@ const ALLOWED_FILE_EXT: &[&str] = &["toml"]; #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct AcmedConfig { - pub global: Option, + pub(in crate::config) global: Option, #[serde(default)] - pub endpoint: Vec, + pub(in crate::config) endpoint: Vec, #[serde(default, rename = "rate-limit")] - pub rate_limit: Vec, + pub(in crate::config) rate_limit: Vec, #[serde(default)] - pub hook: Vec, + pub(in crate::config) hook: Vec, #[serde(default)] - pub group: Vec, + pub(in crate::config) group: Vec, #[serde(default)] - pub account: Vec, + pub(in crate::config) account: Vec, #[serde(default)] - pub certificate: Vec, + pub(in crate::config) certificate: Vec, } pub fn load>(config_dir: P) -> Result { diff --git a/src/config/account.rs b/src/config/account.rs index 402ca0e..269147d 100644 --- a/src/config/account.rs +++ b/src/config/account.rs @@ -6,17 +6,17 @@ use std::collections::HashMap; #[serde(remote = "Self")] #[serde(deny_unknown_fields)] pub struct Account { - pub contacts: Vec, + pub(in crate::config) contacts: Vec, #[serde(default)] - pub env: HashMap, - pub external_account: Option, + pub(in crate::config) env: HashMap, + pub(in crate::config) external_account: Option, #[serde(default)] - pub hooks: Vec, + pub(in crate::config) hooks: Vec, #[serde(default)] - pub key_type: AccountKeyType, - pub name: String, + pub(in crate::config) key_type: AccountKeyType, + pub(in crate::config) name: String, #[serde(default)] - pub signature_algorithm: Option, + pub(in crate::config) signature_algorithm: Option, } impl<'de> Deserialize<'de> for Account { @@ -35,16 +35,16 @@ impl<'de> Deserialize<'de> for Account { #[derive(Clone, Debug, Deserialize, Eq, PartialEq)] #[serde(deny_unknown_fields)] pub struct AccountContact { - pub mailto: String, + pub(in crate::config) mailto: String, } #[derive(Clone, Debug, Deserialize, Eq, PartialEq)] #[serde(deny_unknown_fields)] pub struct ExternalAccount { - pub identifier: String, - pub key: String, + pub(in crate::config) identifier: String, + pub(in crate::config) key: String, #[serde(default)] - pub signature_algorithm: ExternalAccountSignatureAlgorithm, + pub(in crate::config) signature_algorithm: ExternalAccountSignatureAlgorithm, } #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] diff --git a/src/config/certificate.rs b/src/config/certificate.rs index bbaef4a..168043a 100644 --- a/src/config/certificate.rs +++ b/src/config/certificate.rs @@ -9,25 +9,25 @@ use std::path::PathBuf; #[serde(remote = "Self")] #[serde(deny_unknown_fields)] pub struct Certificate { - pub account: String, + pub(in crate::config) account: String, #[serde(default)] - pub csr_digest: CsrDigest, - pub directory: Option, - pub endpoint: String, + pub(in crate::config) csr_digest: CsrDigest, + pub(in crate::config) directory: Option, + pub(in crate::config) endpoint: String, #[serde(default)] - pub env: HashMap, - pub file_name_format: Option, - pub hooks: Vec, - pub identifiers: Vec, + pub(in crate::config) env: HashMap, + pub(in crate::config) file_name_format: Option, + pub(in crate::config) hooks: Vec, + pub(in crate::config) identifiers: Vec, #[serde(default)] - pub key_type: KeyType, + pub(in crate::config) key_type: KeyType, #[serde(default)] - pub kp_reuse: bool, - pub name: Option, - pub random_early_renew: Option, - pub renew_delay: Option, + pub(in crate::config) kp_reuse: bool, + pub(in crate::config) name: Option, + pub(in crate::config) random_early_renew: Option, + pub(in crate::config) renew_delay: Option, #[serde(default)] - pub subject_attributes: SubjectAttributes, + pub(in crate::config) subject_attributes: SubjectAttributes, } impl<'de> Deserialize<'de> for Certificate { @@ -60,11 +60,11 @@ pub enum CsrDigest { #[serde(remote = "Self")] #[serde(deny_unknown_fields)] pub struct Identifier { - pub challenge: AcmeChallenge, - pub dns: Option, + pub(in crate::config) challenge: AcmeChallenge, + pub(in crate::config) dns: Option, #[serde(default)] - pub env: HashMap, - pub ip: Option, + pub(in crate::config) env: HashMap, + pub(in crate::config) ip: Option, } impl<'de> Deserialize<'de> for Identifier { @@ -127,21 +127,21 @@ pub enum KeyType { #[derive(Clone, Debug, Default, Deserialize)] #[serde(deny_unknown_fields)] pub struct SubjectAttributes { - pub country_name: Option, - pub generation_qualifier: Option, - pub given_name: Option, - pub initials: Option, - pub locality_name: Option, - pub name: Option, - pub organization_name: Option, - pub organizational_unit_name: Option, - pub pkcs9_email_address: Option, - pub postal_address: Option, - pub postal_code: Option, - pub state_or_province_name: Option, - pub street: Option, - pub surname: Option, - pub title: Option, + pub(in crate::config) country_name: Option, + pub(in crate::config) generation_qualifier: Option, + pub(in crate::config) given_name: Option, + pub(in crate::config) initials: Option, + pub(in crate::config) locality_name: Option, + pub(in crate::config) name: Option, + pub(in crate::config) organization_name: Option, + pub(in crate::config) organizational_unit_name: Option, + pub(in crate::config) pkcs9_email_address: Option, + pub(in crate::config) postal_address: Option, + pub(in crate::config) postal_code: Option, + pub(in crate::config) state_or_province_name: Option, + pub(in crate::config) street: Option, + pub(in crate::config) surname: Option, + pub(in crate::config) title: Option, } #[cfg(test)] diff --git a/src/config/endpoint.rs b/src/config/endpoint.rs index 65812f8..9a55598 100644 --- a/src/config/endpoint.rs +++ b/src/config/endpoint.rs @@ -4,17 +4,17 @@ use std::path::PathBuf; #[derive(Clone, Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct Endpoint { - pub file_name_format: Option, - pub name: String, - pub random_early_renew: Option, + pub(in crate::config) file_name_format: Option, + pub(in crate::config) name: String, + pub(in crate::config) random_early_renew: Option, #[serde(default)] - pub rate_limits: Vec, - pub renew_delay: Option, + pub(in crate::config) rate_limits: Vec, + pub(in crate::config) renew_delay: Option, #[serde(default)] - pub root_certificates: Vec, + pub(in crate::config) root_certificates: Vec, #[serde(default)] - pub tos_agreed: bool, - pub url: String, + pub(in crate::config) tos_agreed: bool, + pub(in crate::config) url: String, } #[cfg(test)] diff --git a/src/config/global.rs b/src/config/global.rs index 3160d66..f60d6cb 100644 --- a/src/config/global.rs +++ b/src/config/global.rs @@ -6,28 +6,28 @@ use std::path::PathBuf; #[serde(deny_unknown_fields)] pub struct GlobalOptions { #[serde(default = "get_default_accounts_directory")] - pub accounts_directory: PathBuf, - pub cert_file_group: Option, - pub cert_file_mode: Option, - pub cert_file_user: Option, + pub(in crate::config) accounts_directory: PathBuf, + pub(in crate::config) cert_file_group: Option, + pub(in crate::config) cert_file_mode: Option, + pub(in crate::config) cert_file_user: Option, #[serde(default = "get_default_cert_file_ext")] - pub cert_file_ext: String, + pub(in crate::config) cert_file_ext: String, #[serde(default = "get_default_certificates_directory")] - pub certificates_directory: PathBuf, + pub(in crate::config) certificates_directory: PathBuf, #[serde(default)] - pub env: HashMap, + pub(in crate::config) env: HashMap, #[serde(default = "get_default_file_name_format")] - pub file_name_format: String, - pub pk_file_group: Option, - pub pk_file_mode: Option, - pub pk_file_user: Option, + pub(in crate::config) file_name_format: String, + pub(in crate::config) pk_file_group: Option, + pub(in crate::config) pk_file_mode: Option, + pub(in crate::config) pk_file_user: Option, #[serde(default = "get_default_pk_file_ext")] - pub pk_file_ext: String, - pub random_early_renew: Option, + pub(in crate::config) pk_file_ext: String, + pub(in crate::config) random_early_renew: Option, #[serde(default = "get_default_renew_delay")] - pub renew_delay: String, + pub(in crate::config) renew_delay: String, #[serde(default)] - pub root_certificates: Vec, + pub(in crate::config) root_certificates: Vec, } fn get_default_lib_dir() -> PathBuf { diff --git a/src/config/hook.rs b/src/config/hook.rs index d288841..76adb8b 100644 --- a/src/config/hook.rs +++ b/src/config/hook.rs @@ -7,17 +7,17 @@ use std::path::PathBuf; #[serde(deny_unknown_fields)] pub struct Hook { #[serde(default)] - pub allow_failure: bool, + pub(in crate::config) allow_failure: bool, #[serde(default)] - pub args: Vec, - pub cmd: String, - pub name: String, - pub stderr: Option, - pub stdin: Option, - pub stdin_str: Option, - pub stdout: Option, + pub(in crate::config) args: Vec, + pub(in crate::config) cmd: String, + pub(in crate::config) name: String, + pub(in crate::config) stderr: Option, + pub(in crate::config) stdin: Option, + pub(in crate::config) stdin_str: Option, + pub(in crate::config) stdout: Option, #[serde(rename = "type")] - pub hook_type: Vec, + pub(in crate::config) hook_type: Vec, } impl<'de> Deserialize<'de> for Hook { @@ -65,8 +65,8 @@ pub enum HookType { #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct Group { - pub hooks: Vec, - pub name: String, + pub(in crate::config) hooks: Vec, + pub(in crate::config) name: String, } #[cfg(test)] diff --git a/src/config/rate_limit.rs b/src/config/rate_limit.rs index 076c7cf..ada0e83 100644 --- a/src/config/rate_limit.rs +++ b/src/config/rate_limit.rs @@ -3,9 +3,9 @@ use serde_derive::Deserialize; #[derive(Clone, Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct RateLimit { - pub name: String, - pub number: usize, - pub period: String, + pub(in crate::config) name: String, + pub(in crate::config) number: usize, + pub(in crate::config) period: String, } #[cfg(test)]