From 0cd80471d057da043c1c7e386a0730f234cb70a0 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sun, 24 Apr 2022 20:21:57 +0200 Subject: [PATCH] api types: namespace: add from_parent_ns helper will be used in the (recursive) namespace iterator Signed-off-by: Thomas Lamprecht --- pbs-api-types/src/datastore.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 7b279084..40ae3d7a 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -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 { + let mut child = parent.to_owned(); + child.push(name)?; + Ok(child) + } + /// Create a new namespace directly from a vec. /// /// # Safety