Skip to main content

MachineTrans

Trait MachineTrans 

Source
pub trait MachineTrans<X> {
    type Observation;

    // Required methods
    fn transit(&mut self, x: X);
    fn observe(&self) -> Self::Observation;
    fn initial(&mut self);
}
Expand description

A trait that represents a finite state machine (FSM).

§Type Parameters

  • X: The type of the input or event that causes state transitions.

§Associated Types

  • Observation: The type that represents abstract observations of machine states or outputs.

Required Associated Types§

Source

type Observation

An associated type for capturing the machine’s state or output observations.

Required Methods§

Source

fn transit(&mut self, x: X)

Transitions the state machine to a new state based on the input.

This method modifies the machine’s current state according to the specified input x. The exact details of the transition mechanism are determined by the implementer.

§Parameters
  • x: An input value of type X that influences the state change.
Source

fn observe(&self) -> Self::Observation

Makes an observation of the machine’s current state.

This method returns an abstract representation of the state or output of the machine as defined by the Observation associated type.

Source

fn initial(&mut self)

Resets the machine’s state to its initial state.

This method should bring the machine back to its starting condition.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl MachineTrans<u8> for CANFrameMachine

Source§

impl<X, M0, M1> MachineTrans<X> for Comp<M0, M1>
where M0: MachineTrans<X>, <M0 as MachineTrans<X>>::Observation: Final, M1: MachineTrans<<<M0 as MachineTrans<X>>::Observation as Final>::FinalValue>,

Implementation of the MachineTrans trait for the composition of two finite state machines, M0 and M1.

This is applicable when the final values of machine M0 can be used as inputs to machine M1.

A common use case is where M0 processes and decodes some low-level input to generate higher-level inputs for machine M1.