On 2/19/25 13:52, Maximiliano Sandoval wrote:
>> -#[derive(Debug)]
>> +#[derive(Debug, Deserialize)]
>>  #[cfg_attr(test, derive(Eq, PartialEq))]
>> -pub struct NetworkDevice {
>> +pub struct QemuNetworkDevice {
>>      model: NetworkDeviceModel,
>> +    #[serde(rename = "macaddr")]
>> +    mac_address: MacAddress,
>> +    firewall: Option<bool>,
> 
> Why not use `#[serde(default)]` and always get a boolean? The only place
> it is used uses .unwrap_or(false) (unwrap_or_default would be preferable
> imho).

The reasoning for this is that it is modeled 1:1 after what's in the
property string. It works when reading, but when trying to serialize the
struct you then always have to provide the value for firewall and cannot
omit it.

unwrap_or_default() is fine by me, i thought unwrap_or(false) makes it
clearer but I don't mind at all.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to