Crate state_unit

source ·
Expand description

VM state machine unit handling.

A state unit is a VM component (such as a device) that needs to react to changes in the VM state machine. It needs to start, stop, reset, and save/restore with the VM. (Save/restore is not really a state change but is modeled as such since it must be synchronized with actual state changes.)

This module contains types and functions for defining and manipulating state units. It does this in three parts:

  1. It defines an RPC enum StateRequest which is used to request that a state unit change state (start, stop, etc.). Each state unit must handle incoming state requests on a mesh receiver. This is the foundational type of this model.

  2. It defines a type StateUnits, which is a collection of mesh senders for sending StateRequests. This is used to initiate and wait for state changes across all the units in the VMM, handling any required dependency ordering.

  3. It defines a trait StateUnit that can be used to define handlers for each state request. This is an optional convenience; not all state units will have a type that implements this trait.

This model allows for asynchronous, highly concurrent state changes, and it works across process boundaries thanks to mesh.

Structs§

Enums§

Traits§

  • Trait implemented by an object that can act as a state unit.

Functions§

  • Runs a state unit that can handle inspect requests while there is an active state transition.
  • Runs a simple unit that only needs to respond to state requests.