so it can be deserialized from a string Tested-by: Christoph Heiss <c.he...@proxmox.com> Reviewed-by: Christoph Heiss <c.he...@proxmox.com> Signed-off-by: Aaron Lauterer <a.laute...@proxmox.com> --- proxmox-installer-common/src/utils.rs | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/proxmox-installer-common/src/utils.rs b/proxmox-installer-common/src/utils.rs index 36b1d53..f6521eb 100644 --- a/proxmox-installer-common/src/utils.rs +++ b/proxmox-installer-common/src/utils.rs @@ -103,6 +103,17 @@ impl fmt::Display for CidrAddress { } } +impl<'de> Deserialize<'de> for CidrAddress { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: serde::Deserializer<'de>, + { + let s: String = Deserialize::deserialize(deserializer)?; + s.parse() + .map_err(|_| serde::de::Error::custom("invalid CIDR")) + } +} + fn mask_limit(addr: &IpAddr) -> usize { if addr.is_ipv4() { 32 -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel