api: namespace: return popped component

helpful for places where namespaces need to be (re)created

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-05-05 13:47:26 +02:00 committed by Thomas Lamprecht
parent 7a404dc53d
commit bc06c7b4e9
1 changed files with 4 additions and 2 deletions

View File

@ -575,10 +575,12 @@ impl BackupNamespace {
}
/// Pop one level off the namespace hierachy
pub fn pop(&mut self) {
if let Some(dropped) = self.inner.pop() {
pub fn pop(&mut self) -> Option<String> {
let dropped = self.inner.pop();
if let Some(ref dropped) = dropped {
self.len = self.len.saturating_sub(dropped.len() + 1);
}
dropped
}
/// Get the namespace parent as owned BackupNamespace