1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Core node abstraction for RustyFlow.
//!
//! This module defines the fundamental [`Node`] trait that all computation
//! units in RustyFlow must implement.
use crateFlowError;
use async_trait;
use Value;
/// The fundamental building block for all computations in RustyFlow.
///
/// A `Node` represents a single computation step that takes a JSON value as input
/// and produces a JSON value as output. Nodes are composable and can be chained
/// together in flows for complex processing pipelines.
///
/// # Example
///
/// ```rust
/// use async_trait::async_trait;
/// use rustyflow::{Node, FlowError};
/// use serde_json::{json, Value};
///
/// struct MultiplyNode {
/// factor: f64,
/// }
///
/// #[async_trait]
/// impl Node for MultiplyNode {
/// async fn call(&self, input: Value) -> Result<Value, FlowError> {
/// let number = input["value"].as_f64()
/// .ok_or_else(|| FlowError::NodeFailed("Expected 'value' field".to_string()))?;
/// Ok(json!({"value": number * self.factor}))
/// }
/// }
/// ```