Trait System

Source
pub trait System<'a> {
    type SystemData: DynamicSystemData<'a>;

    // Required method
    fn run(&mut self, data: Self::SystemData);

    // Provided methods
    fn running_time(&self) -> RunningTime { ... }
    fn accessor<'b>(&'b self) -> AccessorCow<'a, 'b, Self> { ... }
    fn setup(&mut self, res: &mut Resources) { ... }
    fn dispose(self, res: &mut Resources)
       where Self: Sized { ... }
}
Expand description

A System, executed with a set of required Resources.

Required Associated Types§

Source

type SystemData: DynamicSystemData<'a>

The resource bundle required to execute this system.

You will mostly use a tuple of system data (which also implements SystemData). You can also create such a resource bundle by simply deriving SystemData for a struct.

Every SystemData is also a DynamicSystemData.

Required Methods§

Source

fn run(&mut self, data: Self::SystemData)

Executes the system with the required system data.

Provided Methods§

Source

fn running_time(&self) -> RunningTime

Returns a hint how long the system needs for running. This is used to optimize the way they’re executed (might allow more parallelization).

Defaults to RunningTime::Average.

Source

fn accessor<'b>(&'b self) -> AccessorCow<'a, 'b, Self>

Return the accessor from the SystemData.

Source

fn setup(&mut self, res: &mut Resources)

Sets up the Resources using Self::SystemData::setup.

Source

fn dispose(self, res: &mut Resources)
where Self: Sized,

Performs clean up that requires resources from the Resources.

This commonly removes components from Resources which depend on external resources.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, P> System<'a> for HierarchySystem<P>
where P: Component + Parent + Send + Sync + 'static, <P as Component>::Storage: Tracked,

Implementors§