pub struct ActionDef {
pub name: String,
pub display_name: Option<String>,
pub description: Option<String>,
pub inputs: Vec<InputDef>,
pub preconditions: Vec<String>,
pub effects: Vec<String>,
pub transition_trigger: Option<String>,
}Expand description
A business operation schema describing what an action does and what it needs.
Actions are the verbs of a service: “submit order”, “approve review”, “send invoice”. Each action defines its input contract, preconditions that must hold, effects that will occur, and an optional link to a state machine transition.
use ferro_projections::{ActionDef, InputDef, DataType, FieldMeaning};
let action = ActionDef::new("submit_order")
.display_name("Submit Order")
.description("Validates and submits a customer order for processing")
.input(InputDef::new("order_id", DataType::Integer, FieldMeaning::Identifier))
.precondition("has_items")
.precondition("payment_valid")
.effect("notify_customer")
.transition_trigger("submit");Fields§
§name: String§display_name: Option<String>§description: Option<String>§inputs: Vec<InputDef>§preconditions: Vec<String>§effects: Vec<String>§transition_trigger: Option<String>Implementations§
Source§impl ActionDef
impl ActionDef
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a new action 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 action description.
Sourcepub fn precondition(self, guard: impl Into<String>) -> Self
pub fn precondition(self, guard: impl Into<String>) -> Self
Adds a precondition guard name that must hold before this action can execute.
Sourcepub fn effect(self, effect: impl Into<String>) -> Self
pub fn effect(self, effect: impl Into<String>) -> Self
Adds an effect name that occurs when this action executes.
Sourcepub fn transition_trigger(self, trigger: impl Into<String>) -> Self
pub fn transition_trigger(self, trigger: impl Into<String>) -> Self
Sets the state machine transition that this action triggers.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ActionDef
impl<'de> Deserialize<'de> for ActionDef
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 ActionDef
impl JsonSchema for ActionDef
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 Eq for ActionDef
impl StructuralPartialEq for ActionDef
Auto Trait Implementations§
impl Freeze for ActionDef
impl RefUnwindSafe for ActionDef
impl Send for ActionDef
impl Sync for ActionDef
impl Unpin for ActionDef
impl UnsafeUnpin for ActionDef
impl UnwindSafe for ActionDef
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