rstm_rules/
lib.rs

1/*
2    Appellation: rstm-rules <library>
3    Created At: 2025.08.30:18:45:29
4    Contrib: @FL03
5*/
6//! Rules for the rstm framework
7
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::{
30    error::*,
31    rule::{LearnedRule, Rule},
32    traits::*,
33    types::*,
34};
35
36#[cfg(feature = "alloc")]
37#[doc(inline)]
38pub use self::program::*;
39#[cfg(feature = "std")]
40#[doc(inline)]
41pub use self::rule_map::RuleMap;
42
43pub mod error;
44pub(crate) mod rule;
45
46#[cfg(feature = "alloc")]
47pub mod program;
48#[cfg(feature = "std")]
49pub mod rule_map;
50
51pub mod traits {
52    //! the traits defining compatible rules within the framework
53    #[doc(inline)]
54    pub use self::prelude::*;
55
56    mod instruction;
57    mod rulespace;
58
59    mod prelude {
60        #[doc(inline)]
61        pub use super::instruction::*;
62        #[doc(inline)]
63        pub use super::rulespace::*;
64    }
65}
66
67mod types {
68    //! types essential to the construction of rules, programs, and other related objects
69    #[doc(inline)]
70    pub use self::prelude::*;
71
72    mod prelude {
73        #[doc(inline)]
74        pub use super::aliases::*;
75    }
76
77    mod aliases {
78        #[cfg(feature = "std")]
79        use rstm_core::{Head, Tail};
80
81        #[cfg(feature = "alloc")]
82        pub(crate) type RuleVec<Q, S> = alloc::vec::Vec<crate::Rule<Q, S>>;
83
84        /// A type alias for a [`HashMap`](std::collections::HashMap) with keys of type [`Head<Q, S>`] and values of type
85        /// [`Tail<Q, S>`].
86        #[cfg(feature = "std")]
87        pub type HeadMap<Q = usize, S = usize> = std::collections::HashMap<Head<Q, S>, Tail<Q, S>>;
88    }
89}
90
91#[doc(hidden)]
92pub mod prelude {
93    #[doc(no_inline)]
94    pub use crate::rule::Rule;
95    #[doc(no_inline)]
96    pub use crate::traits::*;
97    #[doc(no_inline)]
98    pub use crate::types::*;
99
100    #[doc(no_inline)]
101    #[cfg(feature = "alloc")]
102    pub use crate::program::Program;
103    #[doc(no_inline)]
104    #[cfg(feature = "std")]
105    pub use crate::rule_map::RuleMap;
106}