Trait System

Source
pub unsafe trait System {
    // Required methods
    fn is_local(&self) -> bool;
    fn world_access(&self) -> Option<Access>;
    fn visit_archetype(&self, archetype: &Archetype) -> bool;
    fn component_access(
        &self,
        archetype: &Archetype,
        comp: &ComponentInfo,
    ) -> Option<Access>;
    fn resource_type_access(&self, ty: TypeId) -> Option<Access>;
    unsafe fn run_unchecked(
        &mut self,
        world: NonNull<World>,
        queue: &mut dyn ActionBufferQueue,
    );

    // Provided methods
    fn run(&mut self, world: &mut World, queue: &mut dyn ActionBufferQueue) { ... }
    fn run_alone(&mut self, world: &mut World) { ... }
}
Expand description

System that can run using reference to World.

System::is_local method returns true for local systems. Such system may be run only on thread where World lives.

System::run_unchecked call is unsafe:

  • running local system outside local thread may cause undefined behavior.
  • running system for which System::world_access returns [Some(Access::Write)] in parallel with system for which System::world_access returns [Some(_)] may cause undefined behavior.

§Safety

If System::is_local() returns false System::run_unchecked must be safe to call from any thread. Otherwise System::run_unchecked must be safe to call from local thread. System::run_unchecked must be safe to call in parallel with any system if System::world_access returns None. System::run_unchecked must be safe to call in parallel with other systems if for all of them System::world_access returns [Some(Access::Read)].

Required Methods§

Source

fn is_local(&self) -> bool

Returns true for local systems that can be run only on thread where World lives.

Source

fn world_access(&self) -> Option<Access>

Returns access type performed on the entire World. Most systems will return some Access::Read, and few will return none.

Source

fn visit_archetype(&self, archetype: &Archetype) -> bool

Checks if any query of this system will visit specified archetype.

Source

fn component_access( &self, archetype: &Archetype, comp: &ComponentInfo, ) -> Option<Access>

Returns access type to the specified component type this system may perform.

Source

fn resource_type_access(&self, ty: TypeId) -> Option<Access>

Returns access type to the specified resource type this system may perform.

Source

unsafe fn run_unchecked( &mut self, world: NonNull<World>, queue: &mut dyn ActionBufferQueue, )

Runs the system with given context instance.

If is_local() returns true then running it outside local thread is unsound.

Provided Methods§

Source

fn run(&mut self, world: &mut World, queue: &mut dyn ActionBufferQueue)

Runs the system with exclusive access to World.

Source

fn run_alone(&mut self, world: &mut World)

Runs the system with exclusive access to World and flushes action buffers immediately.

Implementors§

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)>
where A: System, B: System, C: System, D: System, E: System, F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)>
where B: System, C: System, D: System, E: System, F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<C, D, E, F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(C, D, E, F, G, H, I, J, K, L, M, N, O, P)>
where C: System, D: System, E: System, F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<D, E, F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(D, E, F, G, H, I, J, K, L, M, N, O, P)>
where D: System, E: System, F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<E, F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(E, F, G, H, I, J, K, L, M, N, O, P)>
where E: System, F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<F, G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(F, G, H, I, J, K, L, M, N, O, P)>
where F: System, G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<G, H, I, J, K, L, M, N, O, P> System for SystemSequence<(G, H, I, J, K, L, M, N, O, P)>
where G: System, H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<H, I, J, K, L, M, N, O, P> System for SystemSequence<(H, I, J, K, L, M, N, O, P)>
where H: System, I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<I, J, K, L, M, N, O, P> System for SystemSequence<(I, J, K, L, M, N, O, P)>
where I: System, J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<J, K, L, M, N, O, P> System for SystemSequence<(J, K, L, M, N, O, P)>
where J: System, K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<K, L, M, N, O, P> System for SystemSequence<(K, L, M, N, O, P)>
where K: System, L: System, M: System, N: System, O: System, P: System,

Source§

impl<L, M, N, O, P> System for SystemSequence<(L, M, N, O, P)>
where L: System, M: System, N: System, O: System, P: System,

Source§

impl<M, N, O, P> System for SystemSequence<(M, N, O, P)>
where M: System, N: System, O: System, P: System,

Source§

impl<N, O, P> System for SystemSequence<(N, O, P)>
where N: System, O: System, P: System,

Source§

impl<O, P> System for SystemSequence<(O, P)>
where O: System, P: System,

Source§

impl<P> System for SystemSequence<(P,)>
where P: System,

Source§

impl<S> System for IntoLocalSystem<S>
where S: LocalSystem,