pub trait SystemParamFunction<Marker>: Send + 'static {
type Param: SystemParam;
type State: SystemParamState;
// Required methods
fn build_access(state: &Self::State) -> Access;
unsafe fn run_unsafe(&mut self, state: &mut Self::State, world: &mut World);
}Expand description
Trait for functions that can be used as systems.
This trait connects a function signature to its:
- Parameter type (implementing
SystemParam) - Cached state type (implementing
SystemParamState) - Execution method
This trait is automatically implemented for functions with valid system parameter signatures. You don’t need to implement it manually.
§Type Parameters
Marker: A marker type used to disambiguate different function arities
§Safety
Implementations must ensure that parameter access patterns are accurately reported to enable safe parallel execution.
Required Associated Types§
Sourcetype Param: SystemParam
type Param: SystemParam
The combined system parameter type for all function parameters.
Sourcetype State: SystemParamState
type State: SystemParamState
The combined state type for all parameters.
Required Methods§
Sourcefn build_access(state: &Self::State) -> Access
fn build_access(state: &Self::State) -> Access
Builds the access pattern for this function’s parameters.
Sourceunsafe fn run_unsafe(&mut self, state: &mut Self::State, world: &mut World)
unsafe fn run_unsafe(&mut self, state: &mut Self::State, world: &mut World)
Runs the function with parameters extracted from the world.
§Safety
The caller must ensure exclusive access to the world. The implementation uses unsafe code internally to extract multiple parameters, which is safe because the access patterns are tracked and conflict detection ensures no aliasing occurs at runtime.
§Arguments
state- Mutable reference to cached parameter stateworld- Mutable reference to the world
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.