rstm_programs/
lib.rs

1/*
2    Appellation: rstm-programs <library>
3    Created At: 2025.08.30:18:45:29
4    Contrib: @FL03
5*/
6//! The [`programs`](self) module provides various structures and utilities for defining and
7//! managing Turing machine programs, including rules, rule spaces, and program execution.
8#![allow(
9    clippy::module_inception,
10    clippy::new_ret_no_self,
11    clippy::needless_doctest_main,
12    clippy::should_implement_trait
13)]
14#![cfg_attr(not(feature = "std"), no_std)]
15#![cfg_attr(feature = "nightly", feature(allocator_api))]
16
17#[cfg(feature = "alloc")]
18extern crate alloc;
19
20extern crate rstm_core as rstm;
21
22#[macro_use]
23mod macros {
24    #[macro_use]
25    pub(crate) mod seal;
26}
27
28#[doc(inline)]
29pub use self::{error::*, traits::*, types::*};
30
31#[cfg(feature = "std")]
32#[doc(inline)]
33pub use self::rule_map::RuleMap;
34#[doc(hidden)]
35#[cfg(feature = "alloc")]
36pub use self::ruliad::*;
37
38#[doc(inline)]
39#[cfg(feature = "alloc")]
40pub use self::program::Program;
41
42#[cfg(not(any(feature = "alloc", feature = "std")))]
43compile_error! {
44    "Either the `alloc` or `std` feature must be enabled to use this crate."
45}
46
47pub mod error;
48pub mod program;
49
50#[cfg(feature = "std")]
51pub mod rule_map;
52#[doc(hidden)]
53#[cfg(feature = "alloc")]
54pub mod ruliad;
55
56pub mod traits {
57    //! the traits defining compatible rules within the framework
58    #[doc(inline)]
59    pub use self::prelude::*;
60
61    mod program;
62    mod rulespace;
63
64    mod prelude {
65        #[doc(inline)]
66        pub use super::program::*;
67        #[doc(inline)]
68        pub use super::rulespace::*;
69    }
70}
71
72mod types {
73    //! types essential to the construction of rules, programs, and other related objects
74    #[doc(inline)]
75    pub use self::prelude::*;
76
77    mod prelude {
78        #[doc(inline)]
79        pub use super::aliases::*;
80    }
81
82    mod aliases {
83        #[cfg(feature = "std")]
84        use rstm_core::{Head, Tail};
85
86        #[cfg(feature = "alloc")]
87        pub(crate) type RuleVec<Q, S> = alloc::vec::Vec<rstm_core::Rule<Q, S>>;
88
89        /// A type alias for a [`HashMap`](std::collections::HashMap) with keys of type [`Head<Q, S>`] and values of type
90        /// [`Tail<Q, S>`].
91        #[cfg(feature = "std")]
92        pub type HeadMap<Q = usize, A = usize> = std::collections::HashMap<Head<Q, A>, Tail<Q, A>>;
93    }
94}
95
96#[doc(hidden)]
97pub mod prelude {
98    pub use crate::traits::*;
99    pub use crate::types::*;
100
101    pub use crate::program::Program;
102    #[cfg(feature = "std")]
103    pub use crate::rule_map::RuleMap;
104    // #[cfg(feature = "alloc")]
105    // pub use crate::ruliad::Ruliad;
106}