Trait IntoHandler

Source
pub trait IntoHandler<Marker>: Sized {
    type Handler: Handler;

    // Required method
    fn into_handler(self) -> Self::Handler;

    // Provided methods
    fn no_type_id(self) -> NoTypeId<Self::Handler> { ... }
    fn high(self) -> HighPriority<Self::Handler> { ... }
    fn low(self) -> LowPriority<Self::Handler> { ... }
}
Expand description

Types which can be converted into Handlers.

This trait is implemented for all functions that return () and whose arguments are all HandlerParams.

Required Associated Types§

Source

type Handler: Handler

The handler type to convert to.

Required Methods§

Source

fn into_handler(self) -> Self::Handler

Performs the conversion into a Handler.

Provided Methods§

Source

fn no_type_id(self) -> NoTypeId<Self::Handler>

Ignore this handler’s reported TypeId. This can be used to add a specific handler to the world more than once.

§Examples
use evenio::prelude::*;

let mut world = World::new();

let id_1 = world.add_handler(my_handler);
let id_2 = world.add_handler(my_handler.no_type_id());
let id_3 = world.add_handler(my_handler);

assert_ne!(id_1, id_2);
assert_eq!(id_1, id_3);
Source

fn high(self) -> HighPriority<Self::Handler>

Returns a wrapper which sets the priority of this handler to HandlerPriority::High.

Source

fn low(self) -> LowPriority<Self::Handler>

Returns a wrapper which sets the priority of this handler to HandlerPriority::Low.

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.

Implementors§

Source§

impl<H> IntoHandler<()> for H
where H: Handler,

Source§

impl<Marker, F> IntoHandler<(FunctionHandlerMarker, Marker)> for F
where Marker: 'static, F: HandlerParamFunction<Marker>,