pub struct TypestateAutomaton {
pub num_states: usize,
pub initial: usize,
pub accepting: BTreeSet<usize>,
pub transitions: Vec<BTreeMap<String, usize>>,
pub error_states: BTreeSet<usize>,
}Expand description
Represents a finite-state automaton for resource protocol checking.
States are usize indices; transitions are labeled by operation names.
Fields§
§num_states: usizeNumber of states.
initial: usizeInitial state.
accepting: BTreeSet<usize>Accepting (final) states.
transitions: Vec<BTreeMap<String, usize>>Transition table: transitions[state][op_name] = next_state.
error_states: BTreeSet<usize>Error states (invalid transitions recorded here).
Implementations§
Source§impl TypestateAutomaton
impl TypestateAutomaton
Sourcepub fn add_transition(&mut self, from: usize, op: &str, to: usize)
pub fn add_transition(&mut self, from: usize, op: &str, to: usize)
Add a transition: from from via op to to.
Sourcepub fn set_accepting(&mut self, state: usize)
pub fn set_accepting(&mut self, state: usize)
Mark a state as accepting.
Sourcepub fn simulate(&self, ops: &[&str]) -> Option<usize>
pub fn simulate(&self, ops: &[&str]) -> Option<usize>
Simulate an operation sequence; return the final state or None on invalid transition.
Trait Implementations§
Source§impl Clone for TypestateAutomaton
impl Clone for TypestateAutomaton
Source§fn clone(&self) -> TypestateAutomaton
fn clone(&self) -> TypestateAutomaton
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TypestateAutomaton
impl RefUnwindSafe for TypestateAutomaton
impl Send for TypestateAutomaton
impl Sync for TypestateAutomaton
impl Unpin for TypestateAutomaton
impl UnsafeUnpin for TypestateAutomaton
impl UnwindSafe for TypestateAutomaton
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