Skip to main content

SystemParamFunction

Trait SystemParamFunction 

Source
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:

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§

Source

type Param: SystemParam

The combined system parameter type for all function parameters.

Source

type State: SystemParamState

The combined state type for all parameters.

Required Methods§

Source

fn build_access(state: &Self::State) -> Access

Builds the access pattern for this function’s parameters.

Source

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 state
  • world - 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.

Implementors§