pub struct StateDef {
pub name: String,
pub display_name: Option<String>,
pub description: Option<String>,
pub is_final: bool,
pub on_enter: Vec<String>,
pub on_exit: Vec<String>,
pub metadata: Option<Value>,
}Expand description
A state within a state machine.
States can declare entry/exit side effects as string references and carry optional metadata for rendering hints.
Fields§
§name: StringState identifier (e.g., “draft”, “pending”, “completed”).
display_name: Option<String>Human-readable name (e.g., “Pending Review”).
description: Option<String>Description of what this state means.
is_final: boolWhether this is a terminal state.
on_enter: Vec<String>Side effects triggered on entering this state (string references).
on_exit: Vec<String>Side effects triggered on exiting this state (string references).
metadata: Option<Value>Arbitrary metadata for rendering hints.
Implementations§
Source§impl StateDef
impl StateDef
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a new state definition with the given name.
Sourcepub fn display_name(self, name: impl Into<String>) -> Self
pub fn display_name(self, name: impl Into<String>) -> Self
Sets the human-readable display name.
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Sets the description.
Sourcepub fn final_state(self) -> Self
pub fn final_state(self) -> Self
Marks this state as a terminal (final) state.
Sourcepub fn on_enter(self, effects: Vec<impl Into<String>>) -> Self
pub fn on_enter(self, effects: Vec<impl Into<String>>) -> Self
Sets the entry side effects (string references).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for StateDef
impl<'de> Deserialize<'de> for StateDef
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
Source§impl JsonSchema for StateDef
impl JsonSchema for StateDef
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 StateDef
Auto Trait Implementations§
impl Freeze for StateDef
impl RefUnwindSafe for StateDef
impl Send for StateDef
impl Sync for StateDef
impl Unpin for StateDef
impl UnsafeUnpin for StateDef
impl UnwindSafe for StateDef
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