Trait bones_framework::prelude::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> SystemParam for Option<Res<'a, T>>
where T: HasSchema,

§

type State = AtomicResource<T>

§

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

source§

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

source§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

source§

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§

source§

impl SystemParam for &World

§

type State = ()

§

type Param<'s> = &'s World

source§

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

source§

impl<'a, Core, Pack> SystemParam for AllPacksData<'a, Core, Pack>
where Core: HasSchema, Pack: HasSchema,

§

type State = (<Root<'a, Core> as SystemParam>::State, <Packs<'a, Pack> as SystemParam>::State)

§

type Param<'s> = AllPacksData<'s, Core, Pack>

source§

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

source§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AtomicResource<T>

§

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

source§

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

§

type State = AssetServer

§

type Param<'s> = Packs<'s, T>

source§

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

§

type State = AssetServer

§

type Param<'s> = Root<'s, T>

source§

impl<T: HasSchema> SystemParam for Localization<'_, T>