api types: namespace: add from_parent_ns helper

will be used in the (recursive) namespace iterator

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-24 20:21:57 +02:00
parent c2425132c4
commit 02ec2ae9b8

View File

@ -553,6 +553,16 @@ impl BackupNamespace {
Ok(this)
}
/// Create a new Namespace attached to parent
///
/// `name` must be a single level namespace ID, that is, no '/' is allowed.
/// This rule also avoids confusion about the name being a NS or NS-path
pub fn from_parent_ns(parent: &Self, name: String) -> Result<Self, Error> {
let mut child = parent.to_owned();
child.push(name)?;
Ok(child)
}
/// Create a new namespace directly from a vec.
///
/// # Safety