From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EA8611FF13B for ; Wed, 25 Feb 2026 18:02:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ACE23CE29; Wed, 25 Feb 2026 18:03:40 +0100 (CET) Date: Wed, 25 Feb 2026 18:03:34 +0100 From: Gabriel Goller To: Stefan Hanreich , pve-devel@lists.proxmox.com Subject: Re: [PATCH proxmox-ve-rs 5/9] frr: add template serializer and serialize fabrics using templates Message-ID: Mail-Followup-To: Stefan Hanreich , pve-devel@lists.proxmox.com References: <20260203160246.353351-1-g.goller@proxmox.com> <20260203160246.353351-6-g.goller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20241002-35-39f9a6 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1772038997930 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.064 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1.113 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.358 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.659 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: C5UQYCQHMTVKJTXL4TV3IBXLSHO25HIS X-Message-ID-Hash: C5UQYCQHMTVKJTXL4TV3IBXLSHO25HIS X-MailFrom: g.goller@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: > [snip] > > > @@ -166,76 +73,128 @@ pub enum CommonInterfaceNameError { > > > /// > > > /// FRR itself doesn't enforce any limits, but the kernel does. Linux only allows interface names > > > /// to be a maximum of 16 bytes. This is enforced by this struct. > > > -#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] > > > -pub struct CommonInterfaceName(String); > > > +#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] > > > +pub struct InterfaceName(String); > > > > > > -impl TryFrom<&str> for CommonInterfaceName { > > > - type Error = CommonInterfaceNameError; > > > +impl TryFrom<&str> for InterfaceName { > > > + type Error = InterfaceNameError; > > > > > > fn try_from(value: &str) -> Result { > > > Self::new(value) > > > } > > > } > > > > > > -impl TryFrom for CommonInterfaceName { > > > - type Error = CommonInterfaceNameError; > > > +impl TryFrom for InterfaceName { > > > + type Error = InterfaceNameError; > > > > > > fn try_from(value: String) -> Result { > > > Self::new(value) > > > } > > > } > > > > > > -impl CommonInterfaceName { > > > - pub fn new + Into>(s: T) -> Result { > > > +impl InterfaceName { > > > + pub fn new + Into>(s: T) -> Result { > > > > Is Into as bound necessary here? Anything we can access as str > > reference can be converted into a string anyway? > > Umm I think so because we need a owned String? This way we don't need to force a > clone. I now have this overengineered api type :) : /// Name of a interface, which is common between all protocols. /// /// FRR itself doesn't enforce any limits, but the kernel does. Linux only allows interface names /// to be a maximum of 16 bytes. This is enforced by this struct. #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub struct InterfaceName(String); impl TryFrom<&str> for InterfaceName { type Error = InterfaceNameError; fn try_from(s: &str) -> Result { Self::validate(s).map(Self::from_str_unchecked) } } impl TryFrom for InterfaceName { type Error = InterfaceNameError; fn try_from(value: String) -> Result { if Self::validate(&value).is_ok() { Ok(Self::from_string_unchecked(value)) } else { Err(InterfaceNameError::TooLong) } } } impl InterfaceName { fn validate(s: &str) -> Result<&str, InterfaceNameError> { if s.len() <= 15 { Ok(s) } else { Err(InterfaceNameError::TooLong) } } fn from_string_unchecked(s: String) -> InterfaceName { Self(s) } fn from_str_unchecked(s: &str) -> InterfaceName { Self::from_string_unchecked(s.to_string()) } } > > [snip]