pub struct Axon<In, Out, E, Res = ()> {
pub schematic: Schematic,
/* private fields */
}Expand description
The Axon Builder and Runtime.
Axon represents an executable decision tree.
It is reusable and thread-safe.
§Example
use ranvier_core::prelude::*;
// ...
// Start with an identity Axon (In -> In)
let axon = Axon::<(), (), _>::new("My Axon")
.then(StepA)
.then(StepB);
// Execute multiple times
let res1 = axon.execute((), &mut bus1).await;
let res2 = axon.execute((), &mut bus2).await;Fields§
§schematic: SchematicThe static structure (for visualization/analysis)
Implementations§
Source§impl<In, Out, E, Res> Axon<In, Out, E, Res>
impl<In, Out, E, Res> Axon<In, Out, E, Res>
Sourcepub fn then<Next, Trans>(self, transition: Trans) -> Axon<In, Next, E, Res>
pub fn then<Next, Trans>(self, transition: Trans) -> Axon<In, Next, E, Res>
Chain a transition to this Axon.
Requires the transition to use the SAME resource bundle as the previous steps.
Sourcepub async fn execute(
&self,
input: In,
resources: &Res,
bus: &mut Bus,
) -> Outcome<Out, E>
pub async fn execute( &self, input: In, resources: &Res, bus: &mut Bus, ) -> Outcome<Out, E>
Execute the Axon with the given input and resources.
Sourcepub fn serve_inspector(self, port: u16) -> Self
pub fn serve_inspector(self, port: u16) -> Self
Starts the Ranvier Inspector for this Axon on the specified port. This spawns a background task to serve the Schematic.
Sourcepub fn into_schematic(self) -> Schematic
pub fn into_schematic(self) -> Schematic
Consume and return the Schematic.
Sourcepub fn schematic_export_request(&self) -> Option<SchematicExportRequest>
pub fn schematic_export_request(&self) -> Option<SchematicExportRequest>
Detect schematic export mode from runtime flags.
Supported triggers:
RANVIER_SCHEMATIC=1|true|on|yes--schematic
Optional output path:
RANVIER_SCHEMATIC_OUTPUT=<path>--schematic-output <path>/--schematic-output=<path>--output <path>/--output=<path>(only relevant in schematic mode)
Sourcepub fn maybe_export_and_exit(&self) -> Result<bool>
pub fn maybe_export_and_exit(&self) -> Result<bool>
Export schematic and return true when schematic mode is active.
Use this once after circuit construction and before server/custom loops:
let axon = build_axon();
if axon.maybe_export_and_exit()? {
return Ok(());
}
// Normal runtime path...Sourcepub fn maybe_export_and_exit_with<F>(&self, on_before_exit: F) -> Result<bool>where
F: FnOnce(&SchematicExportRequest),
pub fn maybe_export_and_exit_with<F>(&self, on_before_exit: F) -> Result<bool>where
F: FnOnce(&SchematicExportRequest),
Same as Self::maybe_export_and_exit but allows a custom hook right before export/exit.
This is useful when your app has custom loop/bootstrap behavior and you want to skip or cleanup that logic in schematic mode.
Sourcepub fn export_schematic(&self, request: &SchematicExportRequest) -> Result<()>
pub fn export_schematic(&self, request: &SchematicExportRequest) -> Result<()>
Export schematic according to the provided request.