From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id DC24F1FF0A8 for ; Thu, 20 Aug 2026 16:52:33 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1643F21609; Thu, 20 Aug 2026 16:52:29 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 06/20] pdm-config: subscriptions: rename trait methods to read/write/lock Date: Thu, 20 Aug 2026 16:52:06 +0200 Message-ID: <20260820145220.418032-7-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260820145220.418032-1-l.wagner@proxmox.com> References: <20260820145220.418032-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787237518532 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.750 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: R3TNLXE72B7N4GP2DC7IXEJY3MYO6S7C X-Message-ID-Hash: R3TNLXE72B7N4GP2DC7IXEJY3MYO6S7C X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This makes the use of these less awkward when being called via the trait object itself, e.g. on a dependency injected application context object: app.subscription_key_config().read() instead of app.subscription_key_config().config() Signed-off-by: Lukas Wagner --- lib/pdm-config/src/subscriptions.rs | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/pdm-config/src/subscriptions.rs b/lib/pdm-config/src/subscriptions.rs index a2954418..5be88a13 100644 --- a/lib/pdm-config/src/subscriptions.rs +++ b/lib/pdm-config/src/subscriptions.rs @@ -35,46 +35,46 @@ fn instance() -> &'static (dyn SubscriptionKeyConfig + Send + Sync) { } pub fn lock_config() -> Result { - instance().lock_config() + instance().lock() } pub fn config() -> Result<(SectionConfigData, ConfigDigest), Error> { - instance().config() + instance().read() } pub fn shadow_config() -> Result, Error> { - instance().shadow_config() + instance().read_shadow() } pub fn save_config( config: &SectionConfigData, ) -> Result { - instance().save_config(config) + instance().write(config) } pub fn save_shadow(shadow: &SectionConfigData) -> Result<(), Error> { - instance().save_shadow(shadow) + instance().write_shadow(shadow) } pub trait SubscriptionKeyConfig { - fn config(&self) -> Result<(SectionConfigData, ConfigDigest), Error>; - fn shadow_config(&self) -> Result, Error>; - fn lock_config(&self) -> Result; - fn save_config( + fn read(&self) -> Result<(SectionConfigData, ConfigDigest), Error>; + fn read_shadow(&self) -> Result, Error>; + fn lock(&self) -> Result; + fn write( &self, config: &SectionConfigData, ) -> Result; - fn save_shadow(&self, shadow: &SectionConfigData) -> Result<(), Error>; + fn write_shadow(&self, shadow: &SectionConfigData) -> Result<(), Error>; } pub struct DefaultSubscriptionKeyConfig; impl SubscriptionKeyConfig for DefaultSubscriptionKeyConfig { - fn lock_config(&self) -> Result { + fn lock(&self) -> Result { open_api_lockfile(SUBSCRIPTIONS_CFG_LOCKFILE, None, true) } - fn config(&self) -> Result<(SectionConfigData, ConfigDigest), Error> { + fn read(&self) -> Result<(SectionConfigData, ConfigDigest), Error> { let content = proxmox_sys::fs::file_read_optional_string(SUBSCRIPTIONS_CFG_FILENAME)? .unwrap_or_default(); @@ -85,13 +85,13 @@ impl SubscriptionKeyConfig for DefaultSubscriptionKeyConfig { Ok((data, digest.into())) } - fn shadow_config(&self) -> Result, Error> { + fn read_shadow(&self) -> Result, Error> { let content = proxmox_sys::fs::file_read_optional_string(SUBSCRIPTIONS_SHADOW_FILENAME)? .unwrap_or_default(); SubscriptionKeyShadow::parse_section_config(SUBSCRIPTIONS_SHADOW_FILENAME, &content) } - fn save_config( + fn write( &self, config: &SectionConfigData, ) -> Result { @@ -101,7 +101,7 @@ impl SubscriptionKeyConfig for DefaultSubscriptionKeyConfig { Ok(digest) } - fn save_shadow(&self, shadow: &SectionConfigData) -> Result<(), Error> { + fn write_shadow(&self, shadow: &SectionConfigData) -> Result<(), Error> { let raw = SubscriptionKeyShadow::write_section_config(SUBSCRIPTIONS_SHADOW_FILENAME, shadow)?; // Signed `SubscriptionInfo` blobs are secrets - mode 0600, priv:priv, so the -- 2.47.3