rstm_core/actors/engine_base.rs
1/*
2 Appellation: engine <module>
3 Created At: 2025.08.31:14:49:50
4 Contrib: @FL03
5*/
6use super::Driver;
7use crate::programs::Program;
8use crate::rules::Head;
9use alloc::vec::Vec;
10use rstm_state::RawState;
11
12/// A type alias for an [`EngineBase`] instance configured with a _moving head_ model using
13/// the [`Head<Q, usize>`] structure to maintain the head's position on the tape.
14pub type MovingHead<Q, A> = EngineBase<Head<Q, usize>, Q, A>;
15
16/// The [`EngineBase`] implementation is designed as a type of runtime for executing various
17/// Turing machine models, or drivers, according to a specified set of rules encapsulated
18/// within a [`Program<Q, A>`].
19pub struct EngineBase<D, Q, A>
20where
21 D: Driver<Q, A>,
22 Q: RawState,
23{
24 /// the actor that will be executing the program
25 pub(crate) driver: D,
26 /// the program being executed
27 pub(crate) program: Option<Program<Q, A>>,
28 /// the number of cycles executed; independent of the position of the head on the tape
29 pub(crate) cycles: usize,
30 /// the output tape captures the results of the execution
31 pub(crate) tape: Vec<A>,
32}