On 6/27/24 12:56, Gabriel Goller wrote: > On 26.06.2024 14:15, Stefan Hanreich wrote: >> diff --git a/proxmox-ve-config/src/sdn/mod.rs >> b/proxmox-ve-config/src/sdn/mod.rs >> new file mode 100644 >> index 0000000..4e7c525 >> --- /dev/null >> +++ b/proxmox-ve-config/src/sdn/mod.rs >> @@ -0,0 +1,240 @@ >> +use std::{error::Error, fmt::Display, str::FromStr}; >> + >> +use serde_with::DeserializeFromStr; >> + >> +use crate::firewall::types::Cidr; >> + >> +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] >> +pub enum SdnNameError { >> + Empty, >> + TooLong, >> + InvalidSymbols, >> + InvalidSubnetCidr, >> + InvalidSubnetFormat, >> +} >> + >> +impl Error for SdnNameError {} >> + >> +impl Display for SdnNameError { >> + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { >> + f.write_str(match self { >> + SdnNameError::TooLong => "name too long", >> + SdnNameError::InvalidSymbols => "invalid symbols in name", >> + SdnNameError::InvalidSubnetCidr => "invalid cidr in name", >> + SdnNameError::InvalidSubnetFormat => "invalid format for >> subnet name", >> + SdnNameError::Empty => "name is empty", >> + }) >> + } >> +} >> + > > Hmm, maybe we should pull in the `thiserror` crate here... > There are a few error-enums that could benefit from it: SdnNameError, > IpamError, SdnConfigError, IpRangeError.
Thought about this as well, I guess we depend on it in quite a few crates already - so pulling it in here wouldn't be too bad. _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel