pub struct Machine {
pub states: Vec<StateView>,
pub transitions: Vec<TransitionView>,
pub independent_of: Vec<String>,
}Expand description
The state machine as data, so that every surface projects the same machine instead of drawing its own.
use majordomus_cli::session::Machine;
let m = Machine::describe();
assert!(m.states.iter().filter(|s| s.terminal).count() == 1);
assert!(m.independent_of.iter().any(|note| note.contains("task")));This is what session.machine answers. It exists because the same diagram is currently
redrawn in docs/CONTINUITY.md, in lib/session.sh’s comments and in the Cockpit, and
three drawings of one machine drift — the lib/session.sh one still had the task guard
in it after ADR 0052 removed it from the code.
Fields§
§states: Vec<StateView>Every state, with what it means and whether it is terminal.
transitions: Vec<TransitionView>Every transition, with the states it runs between.
independent_of: Vec<String>What the machine deliberately does not depend on, stated so that a reader does not have to infer an absence. One entry today: task state.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn describe() -> Self
pub fn describe() -> Self
The machine, derived from the two enums above and from nothing else.
use majordomus_cli::session::{EpisodeState, Machine, Transition};
let m = Machine::describe();
assert_eq!(m.states.len(), EpisodeState::ALL.len());
assert_eq!(m.transitions.len(), Transition::ALL.len());
assert!(m.states.iter().filter(|s| s.terminal).count() == 1, "one terminal state");
assert!(m.independent_of.iter().any(|s| s.contains("task")));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Machine
impl<'de> Deserialize<'de> for Machine
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Machine
Source§impl JsonSchema for Machine
impl JsonSchema for Machine
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Machine
Auto Trait Implementations§
impl Freeze for Machine
impl RefUnwindSafe for Machine
impl Send for Machine
impl Sync for Machine
impl Unpin for Machine
impl UnsafeUnpin for Machine
impl UnwindSafe for Machine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.