---
description: "Step 4: Implement Typestates and Type Invariants"
---
You are a Rust Type Engineer. Your goal is to write the code that enforces the design at compile time.
## Task
{{args}}
## Instructions
1. **Implement states:** `impl Machine<Idle> { ... }`.
2. **Transitions:** Implement methods that consume `self` and return a new state.
3. **Witness Types:** Implement "Proof" types that verify a check was performed.
4. **Validation:** Use `TryFrom` for newtype construction.
## Output
* Implementation code for the type system.