From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 86A591FF0C0 for ; Wed, 18 Nov 2026 10:45:55 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 464E6217F7; Wed, 18 Nov 2026 10:44:51 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox v2 20/63] notify: config: rename section config parser/writer methods Date: Wed, 18 Nov 2026 10:43:04 +0100 Message-ID: <20261118094348.273646-21-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118094348.273646-1-l.wagner@proxmox.com> References: <20261118094348.273646-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: 1794995037371 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.197 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: TOKSJOF2J3XOZBA3MSL3HK4RRE6PVQFR X-Message-ID-Hash: TOKSJOF2J3XOZBA3MSL3HK4RRE6PVQFR 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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: `new` and `write` were a bit too generic, so they are renamed to `parse_section_config` and `to_section_config`. The original names were not a big issue, but since we are breaking the public crate API anyway, we might as well improve naming where we can. Signed-off-by: Lukas Wagner --- proxmox-notify/src/api/matcher.rs | 9 +++++---- proxmox-notify/src/api/mod.rs | 2 +- proxmox-notify/src/config.rs | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/proxmox-notify/src/api/matcher.rs b/proxmox-notify/src/api/matcher.rs index 7df30c083..65ceb1dc7 100644 --- a/proxmox-notify/src/api/matcher.rs +++ b/proxmox-notify/src/api/matcher.rs @@ -214,12 +214,12 @@ mod tests { fn empty_config() -> Config { let context = test_context(); - Config::new(&context, "", "").unwrap() + Config::parse_section_config(&context, "", "").unwrap() } fn config_with_two_matchers() -> Config { let context = test_context(); - Config::new( + Config::parse_section_config( &context, " sendmail: foo @@ -501,9 +501,10 @@ matcher: matcher2 // The normalized expression should stay the same after // a read/write cycle of the config - let (raw_config, raw_private_config) = config.write().unwrap(); + let (raw_config, raw_private_config) = config.to_section_config().unwrap(); let context = test_context(); - let config = Config::new(&context, &raw_config, &raw_private_config).unwrap(); + let config = + Config::parse_section_config(&context, &raw_config, &raw_private_config).unwrap(); let matcher = get_matcher(&config, "matcher1")?; assert_eq!(matcher.expression, Some(stored)); diff --git a/proxmox-notify/src/api/mod.rs b/proxmox-notify/src/api/mod.rs index d93cb8353..b70c32df8 100644 --- a/proxmox-notify/src/api/mod.rs +++ b/proxmox-notify/src/api/mod.rs @@ -226,7 +226,7 @@ mod test_helpers { #[allow(unused)] pub fn empty_config() -> Config { let context = test::test_context(); - Config::new(&context, "", "").unwrap() + Config::parse_section_config(&context, "", "").unwrap() } } diff --git a/proxmox-notify/src/config.rs b/proxmox-notify/src/config.rs index f7055b9ff..8c7c84cc8 100644 --- a/proxmox-notify/src/config.rs +++ b/proxmox-notify/src/config.rs @@ -137,8 +137,8 @@ pub struct Config { } impl Config { - /// Parse raw config - pub fn new( + /// Parse notification configuration from section config format. + pub fn parse_section_config( context: &Context, raw_config: &str, raw_private_config: &str, @@ -203,7 +203,7 @@ impl Config { } /// Serialize config - pub fn write(&self) -> Result<(String, String), Error> { + pub fn to_section_config(&self) -> Result<(String, String), Error> { let mut c = self.config.clone(); for (_, (_, value)) in c.sections.iter_mut() { // Remove 'origin' parameter, we do not want it in our -- 2.47.3