pub trait SystemParam {
type Item<'a>;
type State: Default + 'static;
// Required method
fn fetch<'a>(
state: &'a mut Self::State,
world: &'a World,
resources: &'a Resources,
) -> Self::Item<'a>;
}Expand description
Trait implemented for each valid system parameter type.
The macro-generated [impl_system!] blanket implementations use this to
fetch each parameter from the world and resources before calling the system
function. State is per-system storage owned by the FunctionSystem
itself (as opposed to Item, which only lives for the duration of one
call) — this is what lets Local persist between runs.
Required Associated Types§
Required Methods§
fn fetch<'a>( state: &'a mut Self::State, world: &'a World, resources: &'a Resources, ) -> Self::Item<'a>
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<T> SystemParam for Option<AsyncEventWriter<'static, T>>
Soft-access variant of AsyncEventWriter<T>: None instead of panicking
while T isn’t registered via add_async_event
(or BackgroundTasksPlugin
isn’t installed yet). Useful for systems that only opportunistically
spawn background work and shouldn’t hard-fail while the app is still
assembling its plugins.
impl<T> SystemParam for Option<AsyncEventWriter<'static, T>>
Soft-access variant of AsyncEventWriter<T>: None instead of panicking
while T isn’t registered via add_async_event
(or BackgroundTasksPlugin
isn’t installed yet). Useful for systems that only opportunistically
spawn background work and shouldn’t hard-fail while the app is still
assembling its plugins.
Source§impl<T> SystemParam for Option<EventReader<'static, T>>
Soft-access variant of EventReader<T>: None instead of panicking
while T isn’t registered (via App::add_event),
so a system that should just skip when an event type it optionally
consumes hasn’t been set up yet doesn’t have to hard-depend on it. The
read cursor still persists correctly across ticks once the event type
does appear later — it lives in the same per-system State slot either way.
impl<T> SystemParam for Option<EventReader<'static, T>>
Soft-access variant of EventReader<T>: None instead of panicking
while T isn’t registered (via App::add_event),
so a system that should just skip when an event type it optionally
consumes hasn’t been set up yet doesn’t have to hard-depend on it. The
read cursor still persists correctly across ticks once the event type
does appear later — it lives in the same per-system State slot either way.
Source§impl<T> SystemParam for Option<EventWriter<'static, T>>
Soft-access variant of EventWriter<T>: None instead of panicking
while T isn’t registered (via App::add_event).
impl<T> SystemParam for Option<EventWriter<'static, T>>
Soft-access variant of EventWriter<T>: None instead of panicking
while T isn’t registered (via App::add_event).