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".