Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<E> {
    // Required method
    fn run(&mut self, world: &mut World, event: E);

    // Provided methods
    fn inputs_changed(&self, world: &World) -> bool { ... }
    fn name(&self) -> &'static str { ... }
}
Expand description

Object-safe dispatch trait for event handlers.

Enables Box<dyn Handler<E>> for type-erased heterogeneous dispatch. Storage and scheduling are the driver’s responsibility — this trait only defines the dispatch interface.

Takes &mut World — drivers call this directly in their poll loop.

Required Methods§

Source

fn run(&mut self, world: &mut World, event: E)

Run this handler with the given event.

Provided Methods§

Source

fn inputs_changed(&self, world: &World) -> bool

Returns true if any input resource was modified this sequence.

Default returns true (always run). Callback overrides by checking its state via SystemParam::any_changed.

Source

fn name(&self) -> &'static str

Returns the handler’s name.

Default returns "<unnamed>". Callback captures the function’s type_name at construction time.

Implementors§

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static> Handler<E> for Callback<C, F, (P0,)>
where for<'a> &'a mut F: FnMut(&mut C, P0, E) + FnMut(&mut C, P0::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static, P3: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2, P3)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, P3, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static, P3: SystemParam + 'static, P4: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2, P3, P4)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, P3, P4, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static, P3: SystemParam + 'static, P4: SystemParam + 'static, P5: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2, P3, P4, P5)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, P3, P4, P5, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static, P3: SystemParam + 'static, P4: SystemParam + 'static, P5: SystemParam + 'static, P6: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2, P3, P4, P5, P6)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, P3, P4, P5, P6, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>, P6::Item<'a>, E),

Source§

impl<C: 'static, E, F: 'static, P0: SystemParam + 'static, P1: SystemParam + 'static, P2: SystemParam + 'static, P3: SystemParam + 'static, P4: SystemParam + 'static, P5: SystemParam + 'static, P6: SystemParam + 'static, P7: SystemParam + 'static> Handler<E> for Callback<C, F, (P0, P1, P2, P3, P4, P5, P6, P7)>
where for<'a> &'a mut F: FnMut(&mut C, P0, P1, P2, P3, P4, P5, P6, P7, E) + FnMut(&mut C, P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>, P6::Item<'a>, P7::Item<'a>, E),

Source§

impl<C: 'static, E, F: FnMut(&mut C, E) + 'static> Handler<E> for Callback<C, F, ()>

Source§

impl<In: 'static, F: FnMut(&mut World, In) + 'static> Handler<In> for Pipeline<In, F>