ready-active-safe 0.1.3

Lifecycle engine for externally driven systems
Documentation
# ModeChange

A requested change from one mode to another.

Produced inside a [`Decision`](decision.md) when an event triggers a mode
transition. The runtime inspects this value to determine whether the system
should move to a new mode.

`ModeChange` is `#[non_exhaustive]`, so new fields can be added in future
minor versions without breaking downstream code.

## Fields

- `target: M` — the mode to transition to

## Example

```rust
use ready_active_safe::Decision;

#[derive(Debug, Clone, PartialEq, Eq)]
enum Mode { Ready, Active, Safe }

let d: Decision<Mode, ()> = Decision::transition(Mode::Active);
let change = d.mode_change();
assert_eq!(change.map(|mc| &mc.target), Some(&Mode::Active));
```

## Extracting via `into_parts`

```rust
use ready_active_safe::prelude::*;

let d: Decision<&str, &str> = transition("active").emit("go");
let (change, commands) = d.into_parts();

let mc = change.map(|mc| mc.target);
assert_eq!(mc, Some("active"));
assert_eq!(commands, vec!["go"]);
```

## Edge Cases

A stay decision has no `ModeChange`:

```rust
use ready_active_safe::Decision;

let d: Decision<&str, ()> = Decision::stay();
assert!(d.mode_change().is_none());
```

## See Also

- [`Decision`]decision.md — wraps an optional `ModeChange` + commands
- [`Policy`]policy.md — checks whether a `ModeChange` is allowed