langgraph_core_rs/runnable/
base.rs1use async_trait::async_trait;
2use serde_json::Value as JsonValue;
3use langgraph_checkpoint::config::RunnableConfig;
4use crate::types::GraphInterrupt;
5
6#[async_trait]
11pub trait Runnable: Send + Sync {
12 fn invoke(&self, input: &JsonValue, config: &RunnableConfig) -> Result<JsonValue, RunnableError>;
14
15 async fn ainvoke(&self, input: &JsonValue, config: &RunnableConfig) -> Result<JsonValue, RunnableError>;
17
18 fn name(&self) -> &str {
20 std::any::type_name::<Self>()
21 }
22}
23
24#[derive(Debug, thiserror::Error)]
26pub enum RunnableError {
27 #[error("node error: {0}")]
28 Node(String),
29
30 #[error("config error: {0}")]
31 Config(String),
32
33 #[error("channel error: {0}")]
34 Channel(#[from] langgraph_checkpoint::error::ChannelError),
35
36 #[error(transparent)]
37 Other(#[from] Box<dyn std::error::Error + Send + Sync>),
38
39 #[error("runner error: {0}")]
40 Runner(String),
41
42 #[error("graph interrupt")]
43 Interrupt(GraphInterrupt),
44}