pub struct StateMachine {
pub resource_type: String,
pub states: Vec<String>,
pub initial_state: String,
pub transitions: Vec<StateTransition>,
pub sub_scenarios: Vec<SubScenario>,
pub visual_layout: Option<VisualLayout>,
pub metadata: HashMap<String, Value>,
}Expand description
State machine for resource lifecycle management
Fields§
§resource_type: StringResource type this state machine applies to
states: Vec<String>All possible states
initial_state: StringInitial state for new resources
transitions: Vec<StateTransition>Allowed transitions between states
sub_scenarios: Vec<SubScenario>Nested sub-scenarios that can be referenced from this state machine
visual_layout: Option<VisualLayout>Visual layout information for the editor (node positions, edges, etc.)
metadata: HashMap<String, Value>Additional metadata for editor-specific data
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn new(
resource_type: impl Into<String>,
states: Vec<String>,
initial_state: impl Into<String>,
) -> StateMachine
pub fn new( resource_type: impl Into<String>, states: Vec<String>, initial_state: impl Into<String>, ) -> StateMachine
Create a new state machine
Sourcepub fn add_transition(self, transition: StateTransition) -> StateMachine
pub fn add_transition(self, transition: StateTransition) -> StateMachine
Add a transition
Sourcepub fn add_transitions(self, transitions: Vec<StateTransition>) -> StateMachine
pub fn add_transitions(self, transitions: Vec<StateTransition>) -> StateMachine
Add multiple transitions
Sourcepub fn can_transition(&self, from: &str, to: &str) -> bool
pub fn can_transition(&self, from: &str, to: &str) -> bool
Check if a transition is allowed
Sourcepub fn next_states(&self, current: &str) -> Vec<String>
pub fn next_states(&self, current: &str) -> Vec<String>
Get next possible states from current state
Sourcepub fn select_next_state(&self, current: &str) -> Option<String>
pub fn select_next_state(&self, current: &str) -> Option<String>
Select next state based on probabilities
Sourcepub fn add_sub_scenario(self, sub_scenario: SubScenario) -> StateMachine
pub fn add_sub_scenario(self, sub_scenario: SubScenario) -> StateMachine
Add a sub-scenario
Sourcepub fn with_visual_layout(self, layout: VisualLayout) -> StateMachine
pub fn with_visual_layout(self, layout: VisualLayout) -> StateMachine
Set visual layout
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> StateMachine
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> StateMachine
Set metadata value
Sourcepub fn get_sub_scenario(&self, id: &str) -> Option<&SubScenario>
pub fn get_sub_scenario(&self, id: &str) -> Option<&SubScenario>
Get a sub-scenario by ID
Sourcepub fn get_sub_scenario_mut(&mut self, id: &str) -> Option<&mut SubScenario>
pub fn get_sub_scenario_mut(&mut self, id: &str) -> Option<&mut SubScenario>
Get a sub-scenario by ID mutably
Trait Implementations§
Source§impl Clone for StateMachine
impl Clone for StateMachine
Source§fn clone(&self) -> StateMachine
fn clone(&self) -> StateMachine
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 moreSource§impl Debug for StateMachine
impl Debug for StateMachine
Source§impl<'de> Deserialize<'de> for StateMachine
impl<'de> Deserialize<'de> for StateMachine
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StateMachine, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StateMachine, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for StateMachine
impl JsonSchema for StateMachine
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
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 is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§impl Serialize for StateMachine
impl Serialize for StateMachine
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for StateMachine
impl RefUnwindSafe for StateMachine
impl Send for StateMachine
impl Sync for StateMachine
impl Unpin for StateMachine
impl UnsafeUnpin for StateMachine
impl UnwindSafe for StateMachine
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more