Trait bones_ecs::system::SystemParam

source ·
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§

source

type State

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

source

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§

source

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.

source

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§

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

source§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

source§

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

Implementors§

source§

impl SystemParam for &World

§

type State = ()

§

type Param<'s> = &'s World

source§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

impl<'a, T: HasSchema> SystemParam for Comp<'a, T>

source§

impl<'a, T: HasSchema> SystemParam for CompMut<'a, T>