pub trait SystemParam {
type State;
type Item<'w>;
// Required methods
fn init(registry: &Registry) -> Self::State;
unsafe fn fetch<'w>(
world: &'w World,
state: &'w mut Self::State,
) -> Self::Item<'w>;
fn any_changed(state: &Self::State, world: &World) -> bool;
// Provided method
fn resource_id(state: &Self::State) -> Option<ResourceId> { ... }
}Expand description
Trait for types that can be resolved from a Registry at build time
and fetched from World at dispatch time.
Build time: init resolves opaque state (e.g. a
ResourceId) from the registry. This panics if the required type
isn’t registered — giving an early build-time error.
Dispatch time: fetch uses the cached state to produce
a reference in ~3 cycles.
Required Associated Types§
Sourcetype State
type State
Opaque state cached at build time (e.g. ResourceId).
Required Methods§
Sourcefn init(registry: &Registry) -> Self::State
fn init(registry: &Registry) -> Self::State
Resolve state from the registry. Called once at build time.
§Panics
Panics if the required resource is not registered.
Sourcefn any_changed(state: &Self::State, world: &World) -> bool
fn any_changed(state: &Self::State, world: &World) -> bool
Returns true if any resource this param depends on was modified
during the current sequence.
Used by drivers to skip handlers whose inputs haven’t changed.
Provided Methods§
Sourcefn resource_id(state: &Self::State) -> Option<ResourceId>
fn resource_id(state: &Self::State) -> Option<ResourceId>
The ResourceId this param accesses, if any.
Returns None for params that don’t access World resources
(e.g. Local<T>). Used by Registry::check_access to enforce
one borrow per resource per handler.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl SystemParam for ()
Unit impl — event-only handlers with no resource parameters.
impl SystemParam for ()
Unit impl — event-only handlers with no resource parameters.