Skip to main content

Command

Trait Command 

Source
pub trait Command:
    Send
    + Sync
    + 'static {
    type Output: Send + Sync + 'static;
}
Expand description

A message expressing the intent to mutate state.

Each command has exactly one CommandHandler registered with the Mediator. The handler returns the associated Command::Output type.

Implementors should be cheap to clone or move, since the framework owns the command after dispatch.

§Example

use hexeract_core::Command;
use uuid::Uuid;

struct RegisterUser {
    pub email: String,
}

impl Command for RegisterUser {
    type Output = Uuid;
}

Required Associated Types§

Source

type Output: Send + Sync + 'static

The result type returned by the handler upon successful execution.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§