Skip to main content

SystemParam

Trait SystemParam 

Source
pub trait SystemParam {
    type Item<'a>;
    type State: Default + 'static;

    // Required method
    fn fetch<'a>(
        world: &'a World,
        resources: &'a Resources,
        state: &'a mut Self::State,
    ) -> Self::Item<'a>;
}
Expand description

Anything that can be fetched as a system function parameter — implemented for Read/Write, Query, Local, Commands, tuples of SystemParams (so a function can take several), and a few others. You generally don’t implement this yourself unless you’re adding a new kind of parameter.

Required Associated Types§

Source

type Item<'a>

The value actually handed to the system function.

Source

type State: Default + 'static

Per-system persistent state (e.g. Local’s stored value) — () for anything stateless.

Required Methods§

Source

fn fetch<'a>( world: &'a World, resources: &'a Resources, state: &'a mut Self::State, ) -> Self::Item<'a>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a> SystemParam for &'a World

Source§

type Item<'w> = &'w World

Source§

type State = ()

Source§

fn fetch<'w>( world: &'w World, _resources: &'w Resources, _state: &'w mut Self::State, ) -> Self::Item<'w>

Source§

impl<T> SystemParam for Option<EventReader<'static, T>>
where T: 'static + Sync + Send,

Source§

type Item<'a> = Option<EventReader<'a, T>>

Source§

type State = usize

Source§

fn fetch<'a>( world: &'a World, resources: &'a Resources, state: &'a mut Self::State, ) -> Self::Item<'a>

Source§

impl<T> SystemParam for Option<EventWriter<'static, T>>
where T: 'static + Sync + Send,

Source§

type Item<'a> = Option<EventWriter<'a, T>>

Source§

type State = ()

Source§

fn fetch<'a>( world: &'a World, resources: &'a Resources, state: &'a mut Self::State, ) -> Self::Item<'a>

Source§

impl<T> SystemParam for Option<Read<'static, T>>
where T: 'static + Sync + Send,

Source§

type Item<'a> = Option<Read<'a, T>>

Source§

type State = ()

Source§

fn fetch<'a>( world: &'a World, resources: &'a Resources, state: &'a mut Self::State, ) -> Self::Item<'a>

Source§

impl<T> SystemParam for Option<Write<'static, T>>
where T: 'static + Sync + Send,

Source§

type Item<'a> = Option<Write<'a, T>>

Source§

type State = ()

Source§

fn fetch<'a>( world: &'a World, resources: &'a Resources, state: &'a mut Self::State, ) -> Self::Item<'a>

Implementors§

Source§

impl SystemParam for Commands<'_>

Source§

type Item<'w> = Commands<'w>

Source§

type State = ((), (), ())

Source§

impl<'a> SystemParam for &'a Resources

Source§

type Item<'w> = &'w Resources

Source§

type State = ()

Source§

impl<Q> SystemParam for Query<'static, Q>
where Q: Query + 'static,

Source§

type Item<'a> = Query<'a, Q>

Source§

type State = ()

Source§

impl<T: 'static> SystemParam for EventReader<'static, T>

Source§

impl<T: 'static> SystemParam for EventWriter<'static, T>

Source§

type Item<'a> = EventWriter<'a, T>

Source§

type State = ()

Source§

impl<T: 'static> SystemParam for Read<'_, T>

Source§

type Item<'a> = Read<'a, T>

Source§

type State = ()

Source§

impl<T: 'static> SystemParam for Write<'_, T>

Source§

type Item<'a> = Write<'a, T>

Source§

type State = ()

Source§

impl<T: Default + Send + Sync + 'static> SystemParam for Local<'_, T>

Source§

type Item<'w> = Local<'w, T>

Source§

type State = T