Skip to main content

RegistryRef

Struct RegistryRef 

Source
pub struct RegistryRef<'w> { /* private fields */ }
Expand description

Read-only access to the Registry during handler dispatch.

Allows handlers to create new handlers at runtime by calling into_handler or into_callback on the borrowed registry.

No ResourceId needed — the registry is part of World’s structure, not a registered resource.

Methods from Deref<Target = Registry>§

Source

pub fn id<T: 'static>(&self) -> ResourceId

Resolve the ResourceId for a type. Cold path — uses HashMap lookup.

§Panics

Panics if the resource type was not registered.

Source

pub fn try_id<T: 'static>(&self) -> Option<ResourceId>

Try to resolve the ResourceId for a type. Returns None if the type was not registered.

Source

pub fn contains<T: 'static>(&self) -> bool

Returns true if a resource of type T has been registered.

Source

pub fn len(&self) -> usize

Returns the number of registered resources.

Source

pub fn is_empty(&self) -> bool

Returns true if no resources have been registered.

Source

pub fn check_access(&self, accesses: &[(Option<ResourceId>, &str)])

Validate that a set of parameter accesses don’t conflict.

Two accesses conflict when they target the same ResourceId. Called at construction time by into_handler, into_callback, and into_step.

Fast path (≤128 resources): single u128 on the stack, zero heap. Slow path (>128 resources): reusable Vec<u64> owned by Registry — allocated once on first use, then cleared and reused.

§Panics

Panics if any resource is accessed by more than one parameter.

Trait Implementations§

Source§

impl Deref for RegistryRef<'_>

Source§

type Target = Registry

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Registry

Dereferences the value.
Source§

impl Param for RegistryRef<'_>

Source§

type State = ()

Opaque state cached at build time (e.g. ResourceId). Read more
Source§

type Item<'w> = RegistryRef<'w>

The item produced at dispatch time.
Source§

fn init(_registry: &Registry)

Resolve state from the registry. Called once at build time. Read more
Source§

unsafe fn fetch<'w>(world: &'w World, _state: &'w mut ()) -> RegistryRef<'w>

Fetch the item using cached state. Read more
Source§

fn resource_id(state: &Self::State) -> Option<ResourceId>

The ResourceId this param accesses, if any. Read more

Auto Trait Implementations§

§

impl<'w> Freeze for RegistryRef<'w>

§

impl<'w> !RefUnwindSafe for RegistryRef<'w>

§

impl<'w> !Send for RegistryRef<'w>

§

impl<'w> !Sync for RegistryRef<'w>

§

impl<'w> Unpin for RegistryRef<'w>

§

impl<'w> UnsafeUnpin for RegistryRef<'w>

§

impl<'w> !UnwindSafe for RegistryRef<'w>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.