Skip to main content

rstm_state/
state.rs

1/*
2    Appellation: state <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5
6use crate::RawState;
7
8/// The [`State`] wrapper is a generic container used to denote objects being used as a
9/// _state_ in a Turing machine, finite-state machine, or similar computational model.
10#[derive(Clone, Copy, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
11#[cfg_attr(
12    feature = "serde",
13    derive(serde::Deserialize, serde::Serialize),
14    serde(transparent)
15)]
16#[repr(transparent)]
17pub struct State<Q: ?Sized = bool>(pub Q);
18
19/// The [`Halt`] implementation is a binary enum designed to represent either a halting state
20/// or a stepping state within a Turing machine or similar computational model.
21#[derive(
22    Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, strum::EnumCount, strum::EnumIs,
23)]
24#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
25#[repr(C)]
26pub enum Halt<Q = usize, H = Q>
27where
28    Q: RawState,
29    H: RawState,
30{
31    Halt(H),
32    Step(Q),
33}
34
35#[cfg(test)]
36mod tests {}