Skip to main content

SystemParam

Trait SystemParam 

Source
pub unsafe trait SystemParam {
    type Item<'w>;

    // Required methods
    fn access() -> Vec<Access>;
    unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>;
}
Expand description

A type that can be extracted from a World as a system parameter.

§Safety

Implementations must correctly report all data accessed via access(). fetch() may only touch the data declared in access(). The caller guarantees that no other parameter has aliasing mutable access to the same data — enforced at system registration time by conflict detection.

Each resource/component lives in its own heap allocation (Box inside HashMap), so accesses to different TypeIds do not alias even through the same *mut World.

Required Associated Types§

Source

type Item<'w>

The concrete type produced for a given world lifetime.

Required Methods§

Source

fn access() -> Vec<Access>

Declare what world data this parameter accesses.

Source

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Extract the parameter from the world.

§Safety

Caller must guarantee no aliasing mutable access to the data declared in access(). The cell provides field-level access via addr_of! to avoid creating intermediate &World or &mut World references, preventing Stacked Borrows aliasing UB when multiple params are fetched in sequence.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SystemParam for ()

Source§

type Item<'w> = ()

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(_world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam, P3: SystemParam, P4: SystemParam, P5: SystemParam, P6: SystemParam, P7: SystemParam> SystemParam for (P0, P1, P2, P3, P4, P5, P6, P7)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>, <P3 as SystemParam>::Item<'w>, <P4 as SystemParam>::Item<'w>, <P5 as SystemParam>::Item<'w>, <P6 as SystemParam>::Item<'w>, <P7 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam, P3: SystemParam, P4: SystemParam, P5: SystemParam, P6: SystemParam> SystemParam for (P0, P1, P2, P3, P4, P5, P6)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>, <P3 as SystemParam>::Item<'w>, <P4 as SystemParam>::Item<'w>, <P5 as SystemParam>::Item<'w>, <P6 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam, P3: SystemParam, P4: SystemParam, P5: SystemParam> SystemParam for (P0, P1, P2, P3, P4, P5)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>, <P3 as SystemParam>::Item<'w>, <P4 as SystemParam>::Item<'w>, <P5 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam, P3: SystemParam, P4: SystemParam> SystemParam for (P0, P1, P2, P3, P4)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>, <P3 as SystemParam>::Item<'w>, <P4 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam, P3: SystemParam> SystemParam for (P0, P1, P2, P3)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>, <P3 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam, P2: SystemParam> SystemParam for (P0, P1, P2)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>, <P2 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam, P1: SystemParam> SystemParam for (P0, P1)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>, <P1 as SystemParam>::Item<'w>)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Source§

impl<P0: SystemParam> SystemParam for (P0,)

Source§

type Item<'w> = (<P0 as SystemParam>::Item<'w>,)

Source§

fn access() -> Vec<Access>

Source§

unsafe fn fetch<'w>(world: UnsafeWorldCell) -> Self::Item<'w>

Implementors§

Source§

impl SystemParam for Commands<'_>

Source§

type Item<'w> = Commands<'w>

Source§

impl<T: Component> SystemParam for Query<'_, T>

Source§

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

Source§

impl<T: Component> SystemParam for QueryMut<'_, T>

Source§

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

Source§

impl<T: Send + 'static> SystemParam for EventReader<'_, T>

Source§

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

Source§

impl<T: Send + 'static> SystemParam for EventWriter<'_, T>

Source§

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

Source§

impl<T: Send + 'static> SystemParam for Res<'_, T>

Source§

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

Source§

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

Source§

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