Skip to main content

Handler

Trait Handler 

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

    // Provided method
    fn name(&self) -> &'static str { ... }
}
Expand description

Object-safe dispatch trait for event handlers.

Analogous to Bevy’s System trait.

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.

Send is required because handlers live in World (via driver storage like timer wheels), and World is Send. All concrete handler types (Callback, HandlerFn) satisfy this automatically for typical usage (function pointers, ResourceId state, Send context).

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 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<'e, E, H> Handler<&'e E> for Owned<H, E>
where E: ToOwned + 'e + ?Sized, H: Handler<E::Owned> + Send,

Source§

impl<'e, E: Clone + 'e, H: Handler<E> + Send> Handler<&'e E> for Cloned<H>

Source§

impl<C: Send + 'static, E, F: Send + 'static, P0: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + 'static, P6: Param + '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: Send + 'static, E, F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + 'static, P6: Param + 'static, P7: Param + '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: Send + 'static, E, F: FnMut(&mut C, E) + Send + 'static> Handler<E> for Callback<C, F, ()>

Source§

impl<E> Handler<E> for Broadcast<E>

Source§

impl<E, H0, H1> Handler<E> for FanOut<(H0, H1)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2> Handler<E> for FanOut<(H0, H1, H2)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2, H3> Handler<E> for FanOut<(H0, H1, H2, H3)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send, H3: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2, H3, H4> Handler<E> for FanOut<(H0, H1, H2, H3, H4)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send, H3: for<'e> Handler<&'e E> + Send, H4: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2, H3, H4, H5> Handler<E> for FanOut<(H0, H1, H2, H3, H4, H5)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send, H3: for<'e> Handler<&'e E> + Send, H4: for<'e> Handler<&'e E> + Send, H5: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2, H3, H4, H5, H6> Handler<E> for FanOut<(H0, H1, H2, H3, H4, H5, H6)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send, H3: for<'e> Handler<&'e E> + Send, H4: for<'e> Handler<&'e E> + Send, H5: for<'e> Handler<&'e E> + Send, H6: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H0, H1, H2, H3, H4, H5, H6, H7> Handler<E> for FanOut<(H0, H1, H2, H3, H4, H5, H6, H7)>
where H0: for<'e> Handler<&'e E> + Send, H1: for<'e> Handler<&'e E> + Send, H2: for<'e> Handler<&'e E> + Send, H3: for<'e> Handler<&'e E> + Send, H4: for<'e> Handler<&'e E> + Send, H5: for<'e> Handler<&'e E> + Send, H6: for<'e> Handler<&'e E> + Send, H7: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H> Handler<E> for ByRef<H>
where H: for<'e> Handler<&'e E> + Send,

Source§

impl<E, H: Handler<E>> Handler<E> for CatchAssertUnwindSafe<H>

Source§

impl<E: 'static, Chain> Handler<E> for Dag<E, Chain>
where Chain: FnMut(&mut World, E) + Send + 'static,

Source§

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

Source§

impl<K: Blueprint> Handler<<K as Blueprint>::Event> for TemplatedHandler<K>
where <K::Params as Param>::State: Copy,

Source§

impl<K: CallbackBlueprint> Handler<<K as Blueprint>::Event> for TemplatedCallback<K>
where <K::Params as Param>::State: Copy,

Source§

impl<Wire, T, F, H> Handler<Wire> for Adapt<F, H>
where F: FnMut(Wire) -> Option<T> + Send, H: Handler<T>,