pub trait SystemData<'a> {
    fn setup(world: &mut World);
    fn fetch(world: &'a World) -> Self;
    fn reads() -> Vec<ResourceId, Global>;
    fn writes() -> Vec<ResourceId, Global>;
}
Expand description

A static system data that can specify its dependencies at statically (at compile-time). Most system data is a SystemData, the DynamicSystemData type is only needed for very special setups.

You can derive this using the #[derive(SystemData)] macro provided by shred-derive. That is as simple as enabling the shred-derive feature.

Examples

use shred::{Read, ResourceId, SystemData, World, Write};

#[derive(Default)]
pub struct Clock;
#[derive(Default)]
pub struct Timer;

// This will implement `SystemData` for `MySystemData`.
// Please note that this will only work if `SystemData`, `World` and `ResourceId` are included.
#[derive(SystemData)]
pub struct MySystemData<'a> {
    pub clock: Read<'a, Clock>,
    pub timer: Write<'a, Timer>,
}

Required Methods

Sets up the system data for fetching it from the World.

Fetches the system data from World. Note that this is only specified for one concrete lifetime 'a, you need to implement the SystemData trait for every possible lifetime.

Returns all read dependencies as fetched from Self::fetch.

Please note that returning wrong dependencies can lead to a panic.

Returns all write dependencies as fetched from Self::fetch.

Please note that returning wrong dependencies can lead to a panic.

Implementations on Foreign Types

Implementors