pub trait IntoHandler<E, Params> {
type Handler: Handler<E> + 'static;
// Required method
fn into_handler(self, registry: &Registry) -> Self::Handler;
}Expand description
Converts a plain function into a Handler.
Analogous to Bevy’s IntoSystem.
Event E is always the last function parameter. Everything before
it is resolved as Param from a Registry.
§Named functions only
Closures do not work with IntoHandler due to Rust’s HRTB inference
limitations with GATs. Use named fn items instead. This is the same
limitation as Bevy’s system registration.
§Examples
use nexus_rt::{Res, ResMut, IntoHandler, WorldBuilder};
fn tick(counter: Res<u64>, mut flag: ResMut<bool>, event: u32) {
if event > 0 {
*flag = true;
}
}
let mut builder = WorldBuilder::new();
builder.register::<u64>(0);
builder.register::<bool>(false);
let mut handler = tick.into_handler(builder.registry());Required Associated Types§
Required Methods§
Sourcefn into_handler(self, registry: &Registry) -> Self::Handler
fn into_handler(self, registry: &Registry) -> Self::Handler
Convert this function into a handler, resolving parameters from the registry.