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 6AACE1FF0B7 for ; Fri, 13 Nov 2026 16:09:10 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6EEE7216C2; Fri, 13 Nov 2026 16:08:49 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox 03/55] notify: move `Endpoint` trait to endpoint module as pub(crate) Date: Fri, 13 Nov 2026 16:07:36 +0100 Message-ID: <20261113150828.756836-4-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: 1794582523306 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.215 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: CBH5MW6NUAGW6PLZSU4L4IKBZQKV3RGO X-Message-ID-Hash: CBH5MW6NUAGW6PLZSU4L4IKBZQKV3RGO 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: This trait better lives in the endpoint module and is not supposed to be used externally. Fixed a typo in the doc comments along the way, no functional change whatsoever. Signed-off-by: Lukas Wagner --- proxmox-notify/src/endpoints/gotify.rs | 4 +++- proxmox-notify/src/endpoints/mod.rs | 14 ++++++++++++++ proxmox-notify/src/endpoints/sendmail.rs | 4 +++- proxmox-notify/src/endpoints/smtp.rs | 4 +++- proxmox-notify/src/endpoints/webhook.rs | 4 +++- proxmox-notify/src/lib.rs | 16 +++------------- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/proxmox-notify/src/endpoints/gotify.rs b/proxmox-notify/src/endpoints/gotify.rs index 5ef82fd01..6b8499827 100644 --- a/proxmox-notify/src/endpoints/gotify.rs +++ b/proxmox-notify/src/endpoints/gotify.rs @@ -12,7 +12,9 @@ use proxmox_schema::{Updater, api}; use crate::context::context; use crate::renderer::TemplateType; use crate::schema::ENTITY_NAME_SCHEMA; -use crate::{Content, Endpoint, Error, Notification, Origin, Severity, renderer}; +use crate::{Content, Error, Notification, Origin, Severity, renderer}; + +use super::Endpoint; const HTTP_TIMEOUT: Duration = Duration::from_secs(10); diff --git a/proxmox-notify/src/endpoints/mod.rs b/proxmox-notify/src/endpoints/mod.rs index f20bee21f..757b251c1 100644 --- a/proxmox-notify/src/endpoints/mod.rs +++ b/proxmox-notify/src/endpoints/mod.rs @@ -1,3 +1,5 @@ +use crate::{Error, Notification}; + #[cfg(feature = "gotify")] pub mod gotify; #[cfg(feature = "sendmail")] @@ -8,3 +10,15 @@ pub mod smtp; pub mod webhook; mod common; + +/// Notification endpoint trait, implemented by all endpoint plugins +pub(crate) trait Endpoint { + /// Send a notification to this endpoint. + fn send(&self, notification: &Notification) -> Result<(), Error>; + + /// The name/identifier for this endpoint + fn name(&self) -> &str; + + /// Check if the endpoint is disabled + fn disabled(&self) -> bool; +} diff --git a/proxmox-notify/src/endpoints/sendmail.rs b/proxmox-notify/src/endpoints/sendmail.rs index 70f37eced..3f5f66db6 100644 --- a/proxmox-notify/src/endpoints/sendmail.rs +++ b/proxmox-notify/src/endpoints/sendmail.rs @@ -8,7 +8,9 @@ use crate::context; use crate::endpoints::common::mail; use crate::renderer::TemplateType; use crate::schema::{EMAIL_SCHEMA, ENTITY_NAME_SCHEMA, USER_SCHEMA}; -use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; +use crate::{Content, Error, Notification, Origin, renderer}; + +use super::Endpoint; pub(crate) const SENDMAIL_TYPENAME: &str = "sendmail"; diff --git a/proxmox-notify/src/endpoints/smtp.rs b/proxmox-notify/src/endpoints/smtp.rs index 49617e70c..e73151797 100644 --- a/proxmox-notify/src/endpoints/smtp.rs +++ b/proxmox-notify/src/endpoints/smtp.rs @@ -14,7 +14,9 @@ use crate::context::context; use crate::endpoints::common::mail; use crate::renderer::TemplateType; use crate::schema::{EMAIL_SCHEMA, ENTITY_NAME_SCHEMA, USER_SCHEMA}; -use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; +use crate::{Content, Error, Notification, Origin, renderer}; + +use super::Endpoint; pub(crate) const SMTP_TYPENAME: &str = "smtp"; diff --git a/proxmox-notify/src/endpoints/webhook.rs b/proxmox-notify/src/endpoints/webhook.rs index cbb3b1299..47d9e0586 100644 --- a/proxmox-notify/src/endpoints/webhook.rs +++ b/proxmox-notify/src/endpoints/webhook.rs @@ -27,7 +27,9 @@ use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, Updater, ap use crate::context::context; use crate::renderer::TemplateType; use crate::schema::ENTITY_NAME_SCHEMA; -use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; +use crate::{Content, Error, Notification, Origin, renderer}; + +use super::Endpoint; /// This will be used as a section type in the public/private configuration file. pub(crate) const WEBHOOK_TYPENAME: &str = "webhook"; diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs index 270087ffc..846e8315e 100644 --- a/proxmox-notify/src/lib.rs +++ b/proxmox-notify/src/lib.rs @@ -28,6 +28,8 @@ pub mod schema; mod error; pub use error::Error; +use endpoints::Endpoint; + #[api()] #[derive(Clone, Debug, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd)] @@ -85,18 +87,6 @@ pub enum Origin { ModifiedBuiltin, } -/// Notification endpoint trait, implemented by all endpoint plugins -pub trait Endpoint { - /// Send a documentation - fn send(&self, notification: &Notification) -> Result<(), Error>; - - /// The name/identifier for this endpoint - fn name(&self) -> &str; - - /// Check if the endpoint is disabled - fn disabled(&self) -> bool; -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum Content { @@ -463,7 +453,7 @@ impl Bus { } #[cfg(test)] - pub fn add_endpoint(&mut self, endpoint: Box) { + pub(crate) fn add_endpoint(&mut self, endpoint: Box) { self.endpoints.insert(endpoint.name().to_string(), endpoint); } -- 2.47.3