api types: BackupNamespace add pop & parent helpers
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
220b66077c
commit
352e13db9d
|
@ -563,6 +563,25 @@ impl BackupNamespace {
|
||||||
Ok(child)
|
Ok(child)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pop one level off the namespace hierachy
|
||||||
|
pub fn pop(&mut self) {
|
||||||
|
if let Some(dropped) = self.inner.pop() {
|
||||||
|
self.len = self.len.saturating_sub(dropped.len() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the namespace parent as owned BackupNamespace
|
||||||
|
pub fn parent(&self) -> Self {
|
||||||
|
if self.is_root() {
|
||||||
|
return Self::root();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut parent = self.clone();
|
||||||
|
parent.pop();
|
||||||
|
|
||||||
|
parent
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new namespace directly from a vec.
|
/// Create a new namespace directly from a vec.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
|
Loading…
Reference in New Issue