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 EE7F81FF0E3 for ; Tue, 04 Aug 2026 13:39:11 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B9AAE216BE; Tue, 04 Aug 2026 13:39:11 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Tue, 04 Aug 2026 13:39:06 +0200 Message-Id: Subject: Re: [PATCH proxmox 02/16] installer-types: post-hook: factor schema version into proper struct From: "Lukas Wagner" To: "Christoph Heiss" , Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260731143910.936881-1-c.heiss@proxmox.com> <20260731143910.936881-3-c.heiss@proxmox.com> In-Reply-To: <20260731143910.936881-3-c.heiss@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1785843534367 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.240 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_LOW -0.7 Sender listed at https://www.dnswl.org/, low 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: Q4LQHVDC7NZ7QIHIL5B5Q2XKKYAUK6ZO X-Message-ID-Hash: Q4LQHVDC7NZ7QIHIL5B5Q2XKKYAUK6ZO 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 Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri Jul 31, 2026 at 4:35 PM CEST, Christoph Heiss wrote: > This simplifies first and foremost version comparison on consumer sites, > making the schema version actually useful. > > No actual API changes, the version is still serialized to/deserialized > from a plain X.Y string. > > Signed-off-by: Christoph Heiss > --- > proxmox-installer-types/src/answer.rs | 68 +++++++++++++++++++++--- > proxmox-installer-types/src/lib.rs | 18 +++++++ > proxmox-installer-types/src/post_hook.rs | 13 +++-- > 3 files changed, 90 insertions(+), 9 deletions(-) > > diff --git a/proxmox-installer-types/src/answer.rs b/proxmox-installer-ty= pes/src/answer.rs > index 266d6a27..68cac026 100644 > --- a/proxmox-installer-types/src/answer.rs > +++ b/proxmox-installer-types/src/answer.rs > @@ -9,6 +9,7 @@ > use anyhow::{Result, anyhow, bail}; > use serde::{Deserialize, Serialize}; > use std::{ > + cmp::Ordering, > collections::{BTreeMap, HashMap}, > fmt::{self, Display}, > str::FromStr, > @@ -63,6 +64,38 @@ pub const SUBSCRIPTION_KEY_SCHEMA: proxmox_schema::Sch= ema =3D > .max_length(32) > .schema(); > =20 > +/// Represents a (major, minor) schema version tuple. > +#[derive(Copy, Clone, Debug, PartialEq, Eq)] > +pub struct SchemaVersion(pub u32, pub u32); > + > +impl PartialOrd for SchemaVersion { > + fn partial_cmp(&self, other: &Self) -> Option { > + match (self.0.cmp(&other.0), self.1.cmp(&other.1)) { > + (Ordering::Equal, ord) =3D> Some(ord), > + (ord, _) =3D> Some(ord), > + } > + } You could use Ordering::then to simplify this, e.g. Some(self.0.cmp(&other.0).then(self.1.cmp(&other.1))) https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.then You could also use it in the partial_cmp implementation of `ProductVersion`, spotted the same there as well.