Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<Req, Resp> {
    // Required methods
    fn name(&self) -> &'static str;
    fn run(&mut self, request: Req, world: &mut World) -> Result<Resp, String>;
    fn access(&self) -> Vec<Access>;
}
Expand description

Trait-object interface for all handler types.

Parallel to System, but shaped for request/response invocation: the caller supplies a Req value and receives Result<Resp, String> back. SystemParams are injected from the ECS world just as they are in regular systems.

Required Methods§

Source

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

Human-readable handler name (for diagnostics and conflict messages).

Source

fn run(&mut self, request: Req, world: &mut World) -> Result<Resp, String>

Run the handler with the given request against the world.

Source

fn access(&self) -> Vec<Access>

Declare what world data this handler accesses.

Returns the union of all parameter accesses for parameterized handlers.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§