[pve-devel] [PATCH proxmox-ve-rs 07/21] firewall: guest: derive traits according to rust api guidelines

Gabriel Goller g.goller at proxmox.com
Thu Jun 27 12:50:44 CEST 2024


On 26.06.2024 14:15, Stefan Hanreich wrote:
>diff --git a/proxmox-ve-config/src/guest/types.rs b/proxmox-ve-config/src/guest/types.rs
>index 217c537..767ff27 100644
>--- a/proxmox-ve-config/src/guest/types.rs
>+++ b/proxmox-ve-config/src/guest/types.rs
>@@ -1,9 +1,13 @@
> use std::fmt;
> use std::str::FromStr;
>
>+use serde_with::{DeserializeFromStr, SerializeDisplay};
>+

Unnecessary empty line here.

> use anyhow::{format_err, Error};
>
>-#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
>+#[derive(
>+    Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, SerializeDisplay, DeserializeFromStr,
>+)]
> pub struct Vmid(u32);
>
> impl Vmid {
>@@ -34,5 +38,3 @@ impl FromStr for Vmid {
>         ))
>     }
> }
>-
>-serde_plain::derive_deserialize_from_fromstr!(Vmid, "valid vmid");
>diff --git a/proxmox-ve-config/src/guest/vm.rs b/proxmox-ve-config/src/guest/vm.rs
>index 5b5866a..a7ea9bb 100644
>--- a/proxmox-ve-config/src/guest/vm.rs
>+++ b/proxmox-ve-config/src/guest/vm.rs
>@@ -5,12 +5,12 @@ use std::str::FromStr;
> use std::{collections::HashMap, net::Ipv6Addr};
>
> use proxmox_schema::property_string::PropertyIterator;
>+use serde_with::DeserializeFromStr;

Add linebreak between proxmox* imports and third-party imports (Also
while you're at it, you can also pull down the anyhow import)

>
> use crate::firewall::parse::{match_digits, parse_bool};
> use crate::firewall::types::address::{Ipv4Cidr, Ipv6Cidr};
>
>-#[derive(Debug)]
>-#[cfg_attr(test, derive(Eq, PartialEq))]
>+#[derive(Clone, Debug, DeserializeFromStr, PartialEq, Eq, Hash, PartialOrd, Ord)]
> pub struct MacAddress([u8; 6]);
>
> static LOCAL_PART: [u8; 8] = [0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];




More information about the pve-devel mailing list