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>;
// Provided method
fn requires() -> Vec<RequiredResource> { ... }
}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>
Provided Methods§
Sourcefn requires() -> Vec<RequiredResource>
fn requires() -> Vec<RequiredResource>
Resource types this parameter unconditionally needs present to avoid
panicking. Used by App to validate — before
running a non-convergent stage’s systems — that every hard
requirement is already satisfied, failing fast with a clear message
instead of panicking deep inside whichever system happens to run
first.
Empty by default; only hard requirements (bare Res/ResMut)
contribute an entry. Option<Res<T>>/Option<ResMut<T>> tolerate
absence and deliberately opt out of this check.
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 &'static World
impl SystemParam for &'static World
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).