[pve-devel] [PATCH proxmox-ve-rs 06/21] ipset: address: add helper methods

Gabriel Goller g.goller at proxmox.com
Thu Jun 27 12:45:40 CEST 2024


On 26.06.2024 14:15, Stefan Hanreich wrote:
>Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
>---
> proxmox-ve-config/src/firewall/types/address.rs | 10 ++++++++++
> proxmox-ve-config/src/firewall/types/ipset.rs   | 14 ++++++++++++++
> 2 files changed, 24 insertions(+)
>
>diff --git a/proxmox-ve-config/src/firewall/types/address.rs b/proxmox-ve-config/src/firewall/types/address.rs
>index 3238601..962c9d2 100644
>--- a/proxmox-ve-config/src/firewall/types/address.rs
>+++ b/proxmox-ve-config/src/firewall/types/address.rs
>@@ -11,6 +11,16 @@ pub enum Family {
>     V6,
> }
>
>+impl Family {
>+    pub fn is_ipv4(&self) -> bool {
>+        matches!(self, Self::V4)

We don't need the `matches!` here, a `*self == Self::V4` is enough.
Same below.

>+    }
>+
>+    pub fn is_ipv6(&self) -> bool {
>+        matches!(self, Self::V6)
>+    }
>+}
>+
> impl fmt::Display for Family {
>     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
>         match self {





More information about the pve-devel mailing list