Skip to main content

State

Trait State 

Source
pub trait State: 'static {
    type Event;

    // Required method
    fn apply(&mut self, event: Self::Event);
}
Expand description

A trait that your custom state must implement.

Required Associated Types§

Source

type Event

An event type.

Required Methods§

Source

fn apply(&mut self, event: Self::Event)

Your logic of event handling.

Internally called when you call Context::dispatch.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl State for ()

Source§

type Event = ()

Source§

fn apply(&mut self, (): Self::Event)

Implementors§