pub enum Edge<S: State> {
Fixed {
from: String,
to: String,
},
Conditional {
from: String,
router: Arc<dyn Router<S>>,
path_map: PathMap,
},
}Expand description
Edge in a Juncture graph
Edges define the flow of execution between nodes. Fixed edges always route to the same target, while conditional edges use a router function to determine the target based on the current state.
§Examples
ⓘ
use juncture_core::{edge::Edge, State, Node};
use std::sync::Arc;
struct MyState;
impl State for MyState {
type Update = MyStateUpdate;
}
struct MyStateUpdate;
// Fixed edge: routes from "node_a" to "node_b"
let fixed = Edge::<MyState>::Fixed {
from: "node_a".to_string(),
to: "node_b".to_string(),
};
// Conditional edge: routes based on state
let conditional = Edge::<MyState>::Conditional {
from: "router".to_string(),
router: Arc::new(|state: &MyState| {
Box::pin(async move {
Ok(juncture_core::edge::RouteResult::One("target".to_string()))
})
}),
path_map: PathMap::new(),
};Variants§
Fixed
Fixed edge that always routes to the same target
Conditional
Conditional edge that routes based on state
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Edge<S>
impl<S> !RefUnwindSafe for Edge<S>
impl<S> Send for Edge<S>
impl<S> Sync for Edge<S>
impl<S> Unpin for Edge<S>
impl<S> UnsafeUnpin for Edge<S>
impl<S> !UnwindSafe for Edge<S>
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