Skip to main content

ResMut

Struct ResMut 

Source
pub struct ResMut<'w, T: 'static> { /* private fields */ }
Expand description

Mutable reference to a resource in World.

Analogous to Bevy’s ResMut<T>.

Appears in handler function signatures to declare a write dependency. Derefs to the inner value transparently. Stamps the resource’s changed_at sequence on DerefMut — the act of writing is the change signal.

For shared read access, use Res<T>. For optional write access (no panic if unregistered), use Option<ResMut<T>>.

Construction is pub(crate) — only the dispatch layer creates these.

Implementations§

Source§

impl<'w, T: 'static> ResMut<'w, T>

Source

pub fn is_changed(&self) -> bool

Returns true if the resource was modified during the current sequence.

Source

pub fn changed_after(&self, since: Sequence) -> bool

Returns true if the resource was modified after since.

Unlike is_changed (equality check against current sequence), this uses > — suitable for checking whether any event since a prior checkpoint wrote this resource.

Relies on numeric ordering of the underlying u64 counter. Not wrap-safe, but at one increment per event the u64 sequence space takes ~584 years at 1 GHz to exhaust.

Trait Implementations§

Source§

impl<T: Debug + 'static> Debug for ResMut<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: 'static> Deref for ResMut<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: 'static> DerefMut for ResMut<'_, T>

Source§

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

Mutably dereferences the value.
Source§

impl<T: 'static> Param for ResMut<'_, T>

Source§

type State = ResourceId

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

type Item<'w> = ResMut<'w, T>

The item produced at dispatch time.
Source§

fn init(registry: &Registry) -> ResourceId

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

unsafe fn fetch<'w>( world: &'w World, state: &'w mut ResourceId, ) -> ResMut<'w, T>

Fetch the item using cached state. Read more
Source§

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

The ResourceId this param accesses, if any. Read more

Auto Trait Implementations§

§

impl<'w, T> Freeze for ResMut<'w, T>

§

impl<'w, T> !RefUnwindSafe for ResMut<'w, T>

§

impl<'w, T> !Send for ResMut<'w, T>

§

impl<'w, T> !Sync for ResMut<'w, T>

§

impl<'w, T> Unpin for ResMut<'w, T>

§

impl<'w, T> UnsafeUnpin for ResMut<'w, T>

§

impl<'w, T> !UnwindSafe for ResMut<'w, 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.