Skip to main content

IntoNodeFunction

Trait IntoNodeFunction 

Source
pub trait IntoNodeFunction {
    // Required method
    fn into_runnable(self, name: &str) -> Arc<dyn Runnable> ;
}
Expand description

Trait for converting closures into node Runnables.

This enables add_node and add_conditional_edges to accept both async and sync closures with a uniform API.

Implemented for:

  • Async closures: Fn(JsonValue, RunnableConfig) -> impl Future<...>
  • Via SyncNodeFn wrapper: sync closures
  • Arc<dyn Runnable>: pre-built runnables

Required Methods§

Source

fn into_runnable(self, name: &str) -> Arc<dyn Runnable>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IntoNodeFunction for Arc<dyn Runnable>

Implement IntoNodeFunction for pre-built runnables.

Source§

fn into_runnable(self, _name: &str) -> Arc<dyn Runnable>

Implementors§

Source§

impl<F, Fut> IntoNodeFunction for F
where F: Fn(Value, RunnableConfig) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, RunnableError>> + Send + 'static,

Source§

impl<F> IntoNodeFunction for NodeFn1<F>
where F: Fn(&Value) -> Result<Value, RunnableError> + Send + Sync + 'static,

Source§

impl<F> IntoNodeFunction for RoutingFn<F>
where F: Fn(&Value) -> String + Send + Sync + 'static,

Source§

impl<F> IntoNodeFunction for SyncNodeFn<F>
where F: Fn(&Value, &RunnableConfig) -> Result<Value, RunnableError> + Send + Sync + 'static,