Skip to main content

CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler<C: Command, R: Serialize>: Send + Sync {
    // Required method
    fn handle(&self, cmd: C) -> Result<R, String>;
}
Expand description

Handler for a command type. Game project implements this.

C is the command type (e.g., SpawnUnit). R is the response type (e.g., () or a result DTO).

Required Methods§

Source

fn handle(&self, cmd: C) -> Result<R, String>

Execute the command and return a response.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§