mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-07 01:27:04 +00:00
api-types: impl Display for FilterType
as the previous commit: simply keep the previous Display impl and call it from out of the new GroupFilter impl Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e98fb9d5b1
commit
01618ea991
@ -422,6 +422,17 @@ impl std::str::FromStr for FilterType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for serializing below, caution!
|
||||||
|
impl std::fmt::Display for FilterType {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
FilterType::BackupType(backup_type) => write!(f, "type:{}", backup_type),
|
||||||
|
FilterType::Group(backup_group) => write!(f, "group:{}", backup_group),
|
||||||
|
FilterType::Regex(regex) => write!(f, "regex:{}", regex.as_str()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GroupFilter {
|
pub struct GroupFilter {
|
||||||
pub is_exclude: bool,
|
pub is_exclude: bool,
|
||||||
@ -456,12 +467,10 @@ impl std::str::FromStr for GroupFilter {
|
|||||||
// used for serializing below, caution!
|
// used for serializing below, caution!
|
||||||
impl std::fmt::Display for GroupFilter {
|
impl std::fmt::Display for GroupFilter {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let exclude = if self.is_exclude { "exclude:" } else { "" };
|
if self.is_exclude {
|
||||||
match &self.filter_type {
|
f.write_str("exclude:")?;
|
||||||
FilterType::BackupType(backup_type) => write!(f, "{}type:{}", exclude, backup_type),
|
|
||||||
FilterType::Group(backup_group) => write!(f, "{}group:{}", exclude, backup_group),
|
|
||||||
FilterType::Regex(regex) => write!(f, "{}regex:{}", exclude, regex.as_str()),
|
|
||||||
}
|
}
|
||||||
|
std::fmt::Display::fmt(&self.filter_type, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user