pub enum Node {
Deterministic(Box<dyn for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync>),
Agent(Box<dyn for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync>),
}Expand description
One executable node.
Variants§
Deterministic(Box<dyn for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync>)
Deterministic Rust closure. Receives &mut World. Cheap; no tokens.
Agent(Box<dyn for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync>)
User-supplied async closure that knows how to run an agent loop.
Receives &mut World. This is the v0.1 escape hatch.
Implementations§
Source§impl Node
impl Node
Sourcepub fn deterministic<F>(f: F) -> Selfwhere
F: for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync + 'static,
pub fn deterministic<F>(f: F) -> Selfwhere
F: for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync + 'static,
Wrap a closure that returns a boxed future. The closure body can borrow
&mut World for the future’s lifetime.
ⓘ
Node::deterministic(|w| Box::pin(async move {
let out = w.runner.exec("git", &["status"], None).await?;
Ok(NodeOutput { transition: Transition::Next, data: ... })
}))pub fn agent<F>(f: F) -> Selfwhere
F: for<'a> Fn(&'a mut World) -> BoxFuture<'a, Result<NodeOutput, HarnessError>> + Send + Sync + 'static,
Auto Trait Implementations§
impl !RefUnwindSafe for Node
impl !UnwindSafe for Node
impl Forget for Node
impl Freeze for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
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