On Thu Jun 26, 2025 at 5:11 PM CEST, Michael Köppl wrote: > Signed-off-by: Michael Köppl <m.koe...@proxmox.com> > --- > proxmox-installer-common/src/utils.rs | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/proxmox-installer-common/src/utils.rs > b/proxmox-installer-common/src/utils.rs > index 8adcec0..1fe6a74 100644 > --- a/proxmox-installer-common/src/utils.rs > +++ b/proxmox-installer-common/src/utils.rs > @@ -18,6 +18,20 @@ pub enum CidrAddressParseError { > InvalidMask(Option<ParseIntError>), > } > > +impl fmt::Display for CidrAddressParseError { > + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > + let msg = match &self { > + CidrAddressParseError::NoDelimiter => { > + String::from("No delimiter for separating address and mask > was found") > + } > + CidrAddressParseError::InvalidAddr(addr_parse_error) => > format!("{addr_parse_error}"), > + CidrAddressParseError::InvalidMask(parse_int_error) => > format!("{:?}", parse_int_error), > + }; > + > + write!(f, "Invalid CIDR: {msg}") > + } > +}
This implementation is refactored/rewritten in patch #7 to directly use write!() everywhere - this should already be done here, instead of implementing it here differently and later rewriting it. > + > /// An IP address (IPv4 or IPv6), including network mask. > /// > /// See the [`IpAddr`] type for more information how IP addresses are > handled. > @@ -109,8 +123,7 @@ impl<'de> Deserialize<'de> for CidrAddress { > D: serde::Deserializer<'de>, > { > let s: String = Deserialize::deserialize(deserializer)?; > - s.parse() > - .map_err(|_| serde::de::Error::custom("invalid CIDR")) > + s.parse().map_err(serde::de::Error::custom) > } > } > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel