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 E7BDB1FF0B7 for ; Fri, 13 Nov 2026 16:11:03 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 58C5921834; Fri, 13 Nov 2026 16:09:42 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox 17/55] notify: move TemplateSource to context module Date: Fri, 13 Nov 2026 16:07:50 +0100 Message-ID: <20261113150828.756836-18-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261113150828.756836-1-l.wagner@proxmox.com> References: <20261113150828.756836-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: 1794582525116 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.213 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: I76E3XWHJ7TFAZUM4SBFMDN44MDVQM2V X-Message-ID-Hash: I76E3XWHJ7TFAZUM4SBFMDN44MDVQM2V 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: The type is mainly used for the context trait, and otherwise we have to pull in the 'renderer' module if we only compile with the 'api-impl' flag (since it pulls in context, which needs TemplateSource). Signed-off-by: Lukas Wagner --- proxmox-notify/src/context/mod.rs | 19 +++++++++++++++++-- proxmox-notify/src/context/test.rs | 3 ++- proxmox-notify/src/renderer/mod.rs | 22 ++++------------------ 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/proxmox-notify/src/context/mod.rs b/proxmox-notify/src/context/mod.rs index 71d94c6e3..fd55dca14 100644 --- a/proxmox-notify/src/context/mod.rs +++ b/proxmox-notify/src/context/mod.rs @@ -1,9 +1,8 @@ -use std::fmt::Debug; +use std::fmt::{Debug, Display}; use std::ops::Deref; use std::sync::Arc; use crate::error::BoxedError; -use crate::renderer::TemplateSource; #[cfg(any(feature = "pve-context", feature = "pbs-context"))] pub mod common; @@ -61,3 +60,19 @@ pub trait ContextImpl: Send + Sync + Debug { source: TemplateSource, ) -> Result, BoxedError>; } + +/// Choose between the provided `vendor` template or its by the user optionally created `override` +#[derive(Copy, Clone)] +pub enum TemplateSource { + Vendor, + Override, +} + +impl Display for TemplateSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TemplateSource::Vendor => f.write_str("vendor"), + TemplateSource::Override => f.write_str("override"), + } + } +} diff --git a/proxmox-notify/src/context/test.rs b/proxmox-notify/src/context/test.rs index b959cb929..8296dbf62 100644 --- a/proxmox-notify/src/context/test.rs +++ b/proxmox-notify/src/context/test.rs @@ -1,7 +1,8 @@ use crate::Context; use crate::context::ContextImpl; use crate::error::BoxedError; -use crate::renderer::TemplateSource; + +use super::TemplateSource; #[derive(Debug)] pub(crate) struct TestContext; diff --git a/proxmox-notify/src/renderer/mod.rs b/proxmox-notify/src/renderer/mod.rs index da6279a1d..55282e204 100644 --- a/proxmox-notify/src/renderer/mod.rs +++ b/proxmox-notify/src/renderer/mod.rs @@ -1,6 +1,6 @@ //! Module for rendering notification templates. -use std::{fmt::Display, time::Duration}; +use std::time::Duration; use handlebars::Context as HandlebarsContext; use handlebars::{ @@ -13,7 +13,9 @@ use tracing::error; use proxmox_human_byte::HumanByte; use proxmox_time::TimeSpan; -use crate::{Context, Error}; +use crate::Context; +use crate::Error; +use crate::context::TemplateSource; mod html; mod plaintext; @@ -178,22 +180,6 @@ impl ValueRenderFunction { } } -/// Choose between the provided `vendor` template or its by the user optionally created `override` -#[derive(Copy, Clone)] -pub enum TemplateSource { - Vendor, - Override, -} - -impl Display for TemplateSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - TemplateSource::Vendor => f.write_str("vendor"), - TemplateSource::Override => f.write_str("override"), - } - } -} - /// Available template types #[derive(Copy, Clone, PartialEq)] pub enum TemplateType { -- 2.47.3