Struct axns::AxNamespace

source ·
pub struct AxNamespace { /* private fields */ }
Expand description

A namespace that contains all user-defined resources.

There are two types of namespaces:

  • Global namespace: this namespace is globally unique and all threads share the resources in it. Resources are statically collected into the axns_resource section, and the global namespace is constructed by the base address of the section (AxNamespace::global).
  • Thread-local namespace: this namespace is per-thread, each thread should call AxNamespace::new_thread_local() to allocate a memory area as its namespace. Layout of resources in global and thread-local namespaces is consistent. Each namespace has its own resources, which may be unique or shared between threads by the Arc wrapper.

Implementations§

source§

impl AxNamespace

source

pub const fn base(&self) -> *mut u8

Returns the base address of the namespace, which points to the start of all resources.

source

pub fn size(&self) -> usize

Returns the size of the namespace (size of all resources).

source

pub fn global() -> Self

Returns the global namespace.

source

pub fn new_thread_local() -> Self

Constructs a new thread-local namespace.

Each thread can have its own namespace instead of the global one, to isolate resources between threads.

This function allocates a memory area to store the thread-local resources, and copies from the global namespace as the initial value.

Trait Implementations§

source§

impl Drop for AxNamespace

source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.