rstm_state/traits/stateful.rs
1/*
2 Appellation: stateful <module>
3 Created At: 2026.01.14:21:42:44
4 Contrib: @FL03
5*/
6use super::RawState;
7use crate::state::State;
8
9/// [`Stateful`] is a trait used to establish an interface for objects that maintain theor own
10/// internal state.
11pub trait Stateful<Q>
12where
13 Q: RawState,
14{
15 /// returns a reference to the current state
16 fn state(&self) -> &State<Q>;
17}
18
19/*
20 ************* Implementations *************
21*/
22impl<U, Q> Stateful<Q> for U
23where
24 U: core::borrow::Borrow<State<Q>>,
25 Q: RawState,
26{
27 fn state(&self) -> &State<Q> {
28 self.borrow()
29 }
30}