pub struct OwnedNamespace { /* private fields */ }Expand description
A cloneable, opaque write-authorization capability for a namespace claimed via
interface::reserve_owned_namespace.
A cloneable, opaque write-authorization capability for a namespace claimed via
crate::interface::reserve_owned_namespace.
All clones of an OwnedNamespace share the same underlying authorization and namespace
data: any clone can write to the namespace, and renaming updates the name observed by
every clone. The namespace, its data, and its ownership record are removed automatically
once the last clone is dropped, or immediately via OwnedNamespace::remove.
Free functions in crate::interface cannot write to a namespace owned by an
OwnedNamespace handle; they return UuidPoolError::UnauthorizedNamespaceWriteAccessError
instead. Only the handle’s own methods (and clones of it) are authorized.
Implementations§
Source§impl OwnedNamespace
impl OwnedNamespace
Sourcepub fn namespace(&self) -> NamespaceString
pub fn namespace(&self) -> NamespaceString
Returns the namespace name currently owned by this handle.
Sourcepub fn reserve_id(&self, context: &str) -> Result<Uuid, UuidPoolError>
pub fn reserve_id(&self, context: &str) -> Result<Uuid, UuidPoolError>
Reserves a new UUID in this namespace using crate::interface::DEFAULT_UUID_BASE
and crate::interface::DEFAULT_MAX_RETRIES.
Sourcepub fn reserve_id_with_base(
&self,
context: &str,
base: u32,
) -> Result<Uuid, UuidPoolError>
pub fn reserve_id_with_base( &self, context: &str, base: u32, ) -> Result<Uuid, UuidPoolError>
Reserves a new UUID in this namespace with a custom base.
Sourcepub fn reserve_id_with(
&self,
context: &str,
base: u32,
max_retries: usize,
) -> Result<Uuid, UuidPoolError>
pub fn reserve_id_with( &self, context: &str, base: u32, max_retries: usize, ) -> Result<Uuid, UuidPoolError>
Reserves a new UUID in this namespace with a custom base and retry count.
Sourcepub fn add_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>
pub fn add_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>
Adds an existing UUID to this namespace and context space.
Sourcepub fn remove_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>
pub fn remove_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>
Removes an existing UUID from this namespace and context space.
Sourcepub fn replace_id(
&self,
context: &str,
old_uuid: Uuid,
new_uuid: Uuid,
) -> Result<(), UuidPoolError>
pub fn replace_id( &self, context: &str, old_uuid: Uuid, new_uuid: Uuid, ) -> Result<(), UuidPoolError>
Replaces an existing UUID with a new UUID within a context.
Sourcepub fn clear_context(&self, context: &str) -> Result<(), UuidPoolError>
pub fn clear_context(&self, context: &str) -> Result<(), UuidPoolError>
Clears the given context and all associated UUIDs.
Sourcepub fn clear_all_contexts(&self) -> Result<(), UuidPoolError>
pub fn clear_all_contexts(&self) -> Result<(), UuidPoolError>
Clears all contexts (and their UUIDs) within this namespace, retaining the namespace itself.
Sourcepub fn drain_context(
&self,
context: &str,
) -> Result<Vec<(ContextString, Uuid)>, UuidPoolError>
pub fn drain_context( &self, context: &str, ) -> Result<Vec<(ContextString, Uuid)>, UuidPoolError>
Removes and returns all UUIDs from the given context.
Sourcepub fn drain_all_contexts(
&self,
) -> Result<Vec<(NamespaceString, ContextString, Uuid)>, UuidPoolError>
pub fn drain_all_contexts( &self, ) -> Result<Vec<(NamespaceString, ContextString, Uuid)>, UuidPoolError>
Removes and returns all contexts (and their UUIDs) within this namespace.
Sourcepub fn rename(&self, new_namespace: &str) -> Result<(), UuidPoolError>
pub fn rename(&self, new_namespace: &str) -> Result<(), UuidPoolError>
Renames this namespace. The new name must be absent or empty, and not owned by another handle. The new name is observed by every clone of this handle.
Sourcepub fn remove(self) -> Result<(), UuidPoolError>
pub fn remove(self) -> Result<(), UuidPoolError>
Explicitly removes this namespace, its data, and its ownership record.
Immediately invalidates every clone of this handle: subsequent calls on any clone
return UuidPoolError::UnauthorizedNamespaceWriteAccessError instead of silently
re-creating the namespace as unowned.