From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 4B0041FF391 for ; Thu, 27 Jun 2024 12:56:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E13B913AE0; Thu, 27 Jun 2024 12:56:58 +0200 (CEST) Date: Thu, 27 Jun 2024 12:56:24 +0200 From: Gabriel Goller To: Proxmox VE development discussion Message-ID: <20240627105624.ezrekkucfdf4cmnb@luna.proxmox.com> References: <20240626121550.292290-1-s.hanreich@proxmox.com> <20240626121550.292290-10-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240626121550.292290-10-s.hanreich@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.057 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH proxmox-ve-rs 09/21] sdn: add name types X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On 26.06.2024 14:15, Stefan Hanreich wrote: >diff --git a/proxmox-ve-config/src/sdn/mod.rs b/proxmox-ve-config/src/sdn/mod.rs >new file mode 100644 >index 0000000..4e7c525 >--- /dev/null >+++ b/proxmox-ve-config/src/sdn/mod.rs >@@ -0,0 +1,240 @@ >+use std::{error::Error, fmt::Display, str::FromStr}; >+ >+use serde_with::DeserializeFromStr; >+ >+use crate::firewall::types::Cidr; >+ >+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] >+pub enum SdnNameError { >+ Empty, >+ TooLong, >+ InvalidSymbols, >+ InvalidSubnetCidr, >+ InvalidSubnetFormat, >+} >+ >+impl Error for SdnNameError {} >+ >+impl Display for SdnNameError { >+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { >+ f.write_str(match self { >+ SdnNameError::TooLong => "name too long", >+ SdnNameError::InvalidSymbols => "invalid symbols in name", >+ SdnNameError::InvalidSubnetCidr => "invalid cidr in name", >+ SdnNameError::InvalidSubnetFormat => "invalid format for subnet name", >+ SdnNameError::Empty => "name is empty", >+ }) >+ } >+} >+ Hmm, maybe we should pull in the `thiserror` crate here... There are a few error-enums that could benefit from it: SdnNameError, IpamError, SdnConfigError, IpRangeError. _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel