Skip to main content

Axon

Struct Axon 

Source
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: Schematic

The static structure (for visualization/analysis)

Implementations§

Source§

impl<In, E, Res> Axon<In, In, E, Res>
where In: Send + Sync + 'static, E: Send + 'static, Res: ResourceRequirement,

Source

pub fn new(label: &str) -> Self

Create a new Axon flow with the given label. This is the preferred entry point per Flat API guidelines.

Source

pub fn start(label: &str) -> Self

Start defining a new Axon flow. This creates an Identity Axon (In -> In) with no initial resource requirements.

Source§

impl<In, Out, E, Res> Axon<In, Out, E, Res>
where In: Send + Sync + 'static, Out: Send + Sync + 'static, E: Send + 'static, Res: ResourceRequirement,

Source

pub fn then<Next, Trans>(self, transition: Trans) -> Axon<In, Next, E, Res>
where Next: Send + Sync + 'static, Trans: Transition<Out, Next, Resources = Res, Error = E> + Clone + Send + Sync + 'static,

Chain a transition to this Axon.

Requires the transition to use the SAME resource bundle as the previous steps.

Source

pub fn branch(self, branch_id: impl Into<String>, label: &str) -> Self

Add a branch point

Source

pub async fn execute( &self, input: In, resources: &Res, bus: &mut Bus, ) -> Outcome<Out, E>

Execute the Axon with the given input and resources.

Source

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.

Source

pub fn schematic(&self) -> &Schematic

Get a reference to the Schematic (structural view).

Source

pub fn into_schematic(self) -> Schematic

Consume and return the Schematic.

Source

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)
Source

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...
Source

pub fn maybe_export_and_exit_with<F>(&self, on_before_exit: F) -> Result<bool>

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.

Source

pub fn export_schematic(&self, request: &SchematicExportRequest) -> Result<()>

Export schematic according to the provided request.

Trait Implementations§

Source§

impl<In, Out, E, Res> Clone for Axon<In, Out, E, Res>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<In, Out, E, Res> Freeze for Axon<In, Out, E, Res>

§

impl<In, Out, E, Res = ()> !RefUnwindSafe for Axon<In, Out, E, Res>

§

impl<In, Out, E, Res> Send for Axon<In, Out, E, Res>

§

impl<In, Out, E, Res> Sync for Axon<In, Out, E, Res>

§

impl<In, Out, E, Res> Unpin for Axon<In, Out, E, Res>

§

impl<In, Out, E, Res = ()> !UnwindSafe for Axon<In, Out, E, Res>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,