Skip to main content

OwnedNamespace

Struct OwnedNamespace 

Source
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

Source

pub fn namespace(&self) -> NamespaceString

Returns the namespace name currently owned by this handle.

Source

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.

Source

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.

Source

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.

Source

pub fn add_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>

Adds an existing UUID to this namespace and context space.

Source

pub fn remove_id(&self, context: &str, uuid: Uuid) -> Result<(), UuidPoolError>

Removes an existing UUID from this namespace and context space.

Source

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.

Source

pub fn clear_context(&self, context: &str) -> Result<(), UuidPoolError>

Clears the given context and all associated UUIDs.

Source

pub fn clear_all_contexts(&self) -> Result<(), UuidPoolError>

Clears all contexts (and their UUIDs) within this namespace, retaining the namespace itself.

Source

pub fn drain_context( &self, context: &str, ) -> Result<Vec<(ContextString, Uuid)>, UuidPoolError>

Removes and returns all UUIDs from the given context.

Source

pub fn drain_all_contexts( &self, ) -> Result<Vec<(NamespaceString, ContextString, Uuid)>, UuidPoolError>

Removes and returns all contexts (and their UUIDs) within this namespace.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for OwnedNamespace

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.