Skip to main content

Local

Struct Local 

Source
pub struct Local<'s, T: Default + 'static> { /* private fields */ }
Expand description

Per-handler local state. Stored inside the dispatch wrapper (e.g. Callback or pipeline Stage), not in World.

Initialized with Default::default() at handler creation time. Mutated freely at dispatch time — each handler/stage instance has its own independent copy.

§Examples

fn count_events(mut count: Local<u64>, event: u32) {
    *count += 1;
    println!("event #{}: {}", *count, event);
}

Trait Implementations§

Source§

impl<T: Default + 'static> Deref for Local<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Default + 'static> DerefMut for Local<'_, T>

Source§

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

Mutably dereferences the value.
Source§

impl<T: Default + 'static> SystemParam for Local<'_, T>

Source§

type State = T

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

type Item<'s> = Local<'s, T>

The item produced at dispatch time.
Source§

fn init(_registry: &Registry) -> T

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

unsafe fn fetch<'s>(_world: &'s World, state: &'s mut T) -> Local<'s, T>

Fetch the item using cached state. Read more
Source§

fn any_changed(_state: &T, _world: &World) -> bool

Returns true if any resource this param depends on was modified during the current sequence. Read more
Source§

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

The ResourceId this param accesses, if any. Read more

Auto Trait Implementations§

§

impl<'s, T> Freeze for Local<'s, T>

§

impl<'s, T> RefUnwindSafe for Local<'s, T>
where T: RefUnwindSafe,

§

impl<'s, T> Send for Local<'s, T>
where T: Send,

§

impl<'s, T> Sync for Local<'s, T>
where T: Sync,

§

impl<'s, T> Unpin for Local<'s, T>

§

impl<'s, T> UnsafeUnpin for Local<'s, T>

§

impl<'s, T> !UnwindSafe for Local<'s, T>

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.