public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 06/20] pdm-config: subscriptions: rename trait methods to read/write/lock
Date: Mon, 17 Aug 2026 14:57:13 +0200	[thread overview]
Message-ID: <20260817125727.454039-7-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260817125727.454039-1-l.wagner@proxmox.com>

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 <l.wagner@proxmox.com>
---
 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<ApiLockGuard, Error> {
-    instance().lock_config()
+    instance().lock()
 }
 
 pub fn config() -> Result<(SectionConfigData<SubscriptionKeyEntry>, ConfigDigest), Error> {
-    instance().config()
+    instance().read()
 }
 
 pub fn shadow_config() -> Result<SectionConfigData<SubscriptionKeyShadow>, Error> {
-    instance().shadow_config()
+    instance().read_shadow()
 }
 
 pub fn save_config(
     config: &SectionConfigData<SubscriptionKeyEntry>,
 ) -> Result<ConfigDigest, Error> {
-    instance().save_config(config)
+    instance().write(config)
 }
 
 pub fn save_shadow(shadow: &SectionConfigData<SubscriptionKeyShadow>) -> Result<(), Error> {
-    instance().save_shadow(shadow)
+    instance().write_shadow(shadow)
 }
 
 pub trait SubscriptionKeyConfig {
-    fn config(&self) -> Result<(SectionConfigData<SubscriptionKeyEntry>, ConfigDigest), Error>;
-    fn shadow_config(&self) -> Result<SectionConfigData<SubscriptionKeyShadow>, Error>;
-    fn lock_config(&self) -> Result<ApiLockGuard, Error>;
-    fn save_config(
+    fn read(&self) -> Result<(SectionConfigData<SubscriptionKeyEntry>, ConfigDigest), Error>;
+    fn read_shadow(&self) -> Result<SectionConfigData<SubscriptionKeyShadow>, Error>;
+    fn lock(&self) -> Result<ApiLockGuard, Error>;
+    fn write(
         &self,
         config: &SectionConfigData<SubscriptionKeyEntry>,
     ) -> Result<ConfigDigest, Error>;
-    fn save_shadow(&self, shadow: &SectionConfigData<SubscriptionKeyShadow>) -> Result<(), Error>;
+    fn write_shadow(&self, shadow: &SectionConfigData<SubscriptionKeyShadow>) -> Result<(), Error>;
 }
 
 pub struct DefaultSubscriptionKeyConfig;
 
 impl SubscriptionKeyConfig for DefaultSubscriptionKeyConfig {
-    fn lock_config(&self) -> Result<ApiLockGuard, Error> {
+    fn lock(&self) -> Result<ApiLockGuard, Error> {
         open_api_lockfile(SUBSCRIPTIONS_CFG_LOCKFILE, None, true)
     }
 
-    fn config(&self) -> Result<(SectionConfigData<SubscriptionKeyEntry>, ConfigDigest), Error> {
+    fn read(&self) -> Result<(SectionConfigData<SubscriptionKeyEntry>, 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<SectionConfigData<SubscriptionKeyShadow>, Error> {
+    fn read_shadow(&self) -> Result<SectionConfigData<SubscriptionKeyShadow>, 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<SubscriptionKeyEntry>,
     ) -> Result<ConfigDigest, Error> {
@@ -101,7 +101,7 @@ impl SubscriptionKeyConfig for DefaultSubscriptionKeyConfig {
         Ok(digest)
     }
 
-    fn save_shadow(&self, shadow: &SectionConfigData<SubscriptionKeyShadow>) -> Result<(), Error> {
+    fn write_shadow(&self, shadow: &SectionConfigData<SubscriptionKeyShadow>) -> 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





  parent reply	other threads:[~2026-08-17 12:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 12:57 [PATCH datacenter-manager/proxmox 00/20] inject application context via API macro for easier integration testing Lukas Wagner
2026-08-17 12:57 ` [PATCH proxmox 01/20] router: introduce shared state Lukas Wagner
2026-08-17 13:26   ` Lukas Wagner
2026-08-20 11:23   ` Lukas Wagner
2026-08-21 13:59   ` Robert Obkircher
2026-08-17 12:57 ` [PATCH proxmox 02/20] rest-server: allow to inject " Lukas Wagner
2026-08-17 12:57 ` [PATCH proxmox 03/20] api-macro: support shared state extraction type Lukas Wagner
2026-08-21 13:59   ` Robert Obkircher
2026-08-17 12:57 ` [PATCH datacenter-manager 04/20] context: promote context to a dir-style module Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 05/20] pdm-config: remotes: rename trait methods to read/write/lock Lukas Wagner
2026-08-17 12:57 ` Lukas Wagner [this message]
2026-08-21 14:00   ` [PATCH datacenter-manager 06/20] pdm-config: subscriptions: " Robert Obkircher
2026-08-17 12:57 ` [PATCH datacenter-manager 07/20] remote iterator: pass remote config reader explicitly Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 08/20] context: introduce a ContextFactory to build application context Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 09/20] context: establish PdmApplication object Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 10/20] context: register PdmApplication in router Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 11/20] parallel fetcher: pass arguments to closure in a single type Lukas Wagner
2026-08-21 14:00   ` Robert Obkircher
2026-08-17 12:57 ` [PATCH datacenter-manager 12/20] parallel fetcher: support a custom client factory Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 13/20] api: sdn: use PdmApplication handle for accessing remotes Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 14/20] tests: add helpers for building API-handler-level integration tests Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 15/20] tests: add example tests for SDN API routes Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 16/20] api-cache: add wrapper type Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 17/20] context: provide api-cache on the app object Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 18/20] api: subscriptions: use PdmApplication instead of globals Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 19/20] pdm-config: subscriptions: drop unused accessor functions Lukas Wagner
2026-08-17 12:57 ` [PATCH datacenter-manager 20/20] tests: add example tests for remote subscription management Lukas Wagner
2026-08-20 14:54 ` superseded: [PATCH datacenter-manager/proxmox 00/20] inject application context via API macro for easier integration testing Lukas Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260817125727.454039-7-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal