synwire_core/runnables/
passthrough.rs1use crate::BoxFuture;
4use crate::error::SynwireError;
5use crate::runnables::config::RunnableConfig;
6use crate::runnables::core::RunnableCore;
7use serde_json::Value;
8
9pub struct RunnablePassthrough;
14
15impl RunnableCore for RunnablePassthrough {
16 fn invoke<'a>(
17 &'a self,
18 input: Value,
19 _config: Option<&'a RunnableConfig>,
20 ) -> BoxFuture<'a, Result<Value, SynwireError>> {
21 Box::pin(async move { Ok(input) })
22 }
23
24 #[allow(clippy::unnecessary_literal_bound)]
25 fn name(&self) -> &str {
26 "RunnablePassthrough"
27 }
28}
29
30#[cfg(test)]
31#[allow(clippy::unwrap_used)]
32mod tests {
33 use super::*;
34
35 #[tokio::test]
36 async fn test_passthrough_forwards_input() {
37 let passthrough = RunnablePassthrough;
38 let input = serde_json::json!({"key": "value", "num": 42});
39 let result = passthrough.invoke(input.clone(), None).await.unwrap();
40 assert_eq!(result, input);
41 }
42
43 #[tokio::test]
44 async fn test_passthrough_name() {
45 assert_eq!(RunnablePassthrough.name(), "RunnablePassthrough");
46 }
47}