pub trait SystemParam: Sized {
    type State;
    type Param<'s>;

    // Required methods
    fn get_state(world: &World) -> Self::State;
    fn borrow<'s>(
        world: &'s World,
        state: &'s mut Self::State
    ) -> Self::Param<'s>;
}
Expand description

Trait used to implement parameters for System functions.

Functions that only take arguments implementing SystemParam automatically implment IntoSystem.

Implementing SystemParam manually can be useful for creating new kinds of parameters you may use in your system funciton arguments. Examples might inlclude event readers and writers or other custom ways to access the data inside a World.

Required Associated Types§

type State

The intermediate state for the parameter, that may be extracted from the world.

type Param<'s>

The type of the parameter, ranging over the lifetime of the intermediate state.

ℹ️ Important: This type must be the same type as Self, other than the fact that it may range over the lifetime 's instead of a generic lifetime from your impl.

If the type is not the same, then system functions will not be able to take it as an argument.

Required Methods§

fn get_state(world: &World) -> Self::State

This is called to produce the intermediate state of the system parameter.

This state will be created immediately before the system is run, and will kept alive until the system is done running.

fn borrow<'s>(world: &'s World, state: &'s mut Self::State) -> Self::Param<'s>

This is used create an instance of the system parame, possibly borrowed from the intermediate parameter state.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<'a, T> SystemParam for Option<Res<'a, T>>where T: HasSchema,

§

type State = AtomicResource<T>

§

type Param<'p> = Option<Res<'p, T>>

§

fn get_state(world: &World) -> <Option<Res<'a, T>> as SystemParam>::State

§

fn borrow<'s>( _world: &'s World, state: &'s mut <Option<Res<'a, T>> as SystemParam>::State ) -> <Option<Res<'a, T>> as SystemParam>::Param<'s>

§

impl<'a, T> SystemParam for Option<ResMut<'a, T>>where T: HasSchema,

§

type State = AtomicResource<T>

§

type Param<'p> = Option<ResMut<'p, T>>

§

fn get_state(world: &World) -> <Option<ResMut<'a, T>> as SystemParam>::State

§

fn borrow<'s>( _world: &'s World, state: &'s mut <Option<ResMut<'a, T>> as SystemParam>::State ) -> <Option<ResMut<'a, T>> as SystemParam>::Param<'s>

Implementors§

§

impl SystemParam for &World

§

type State = ()

§

type Param<'s> = &'s World

§

impl<'a> SystemParam for Commands<'a>

§

impl<'a, T> SystemParam for Ref<'a, ComponentStore<T>>where T: HasSchema,

§

impl<'a, T> SystemParam for RefMut<'a, ComponentStore<T>>where T: HasSchema,

§

impl<'a, T> SystemParam for Res<'a, T>where T: HasSchema,

§

type State = AtomicResource<T>

§

type Param<'p> = Res<'p, T>

§

impl<'a, T> SystemParam for ResInit<'a, T>where T: HasSchema + FromWorld,

§

type State = AtomicResource<T>

§

type Param<'p> = ResInit<'p, T>

§

impl<'a, T> SystemParam for ResMut<'a, T>where T: HasSchema,

§

type State = AtomicResource<T>

§

type Param<'p> = ResMut<'p, T>

§

impl<'a, T> SystemParam for ResMutInit<'a, T>where T: HasSchema + FromWorld,

§

type State = AtomicResource<T>

§

type Param<'p> = ResMutInit<'p, T>