mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-01-31 01:48:09 +03:00
api: add DatastoreWithNamespace helper struct
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
d3a570eb79
commit
40d495de6d
@ -1054,6 +1054,22 @@ impl fmt::Display for BackupDir {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper struct for places where sensible formatting of store+NS combo is required
|
||||||
|
pub struct DatastoreWithNamespace {
|
||||||
|
pub store: String,
|
||||||
|
pub ns: BackupNamespace,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for DatastoreWithNamespace {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if self.ns.is_root() {
|
||||||
|
write!(f, "{}", self.store)
|
||||||
|
} else {
|
||||||
|
write!(f, "{}/{}", self.store, self.ns)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Used when both a backup group or a directory can be valid.
|
/// Used when both a backup group or a directory can be valid.
|
||||||
pub enum BackupPart {
|
pub enum BackupPart {
|
||||||
Group(BackupGroup),
|
Group(BackupGroup),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user