dataflow_rs/engine/functions/mod.rs
1use crate::engine::error::Result;
2use crate::engine::message::{Change, Message};
3use datalogic_rs::DataLogic;
4
5pub mod config;
6pub use config::FunctionConfig;
7
8pub mod validation;
9pub use validation::{ValidationConfig, ValidationRule};
10
11pub mod map;
12pub use map::{MapConfig, MapMapping};
13
14// Re-export all built-in functions for easier access
15pub mod builtins {
16 use super::*;
17
18 // Get all built-in functions with their standard names
19 pub fn get_all_functions() -> Vec<(String, Box<dyn FunctionHandler + Send + Sync>)> {
20 // Map and Validate are now internal to the Engine for better performance
21 // They can directly access compiled logic cache
22 // Add other built-in functions here as needed (HTTP, File I/O, etc.)
23 vec![]
24 }
25}
26
27/// Interface for task functions that operate on messages
28///
29/// ## Usage
30///
31/// Implement this trait for custom processing logic. The function receives:
32/// - Mutable access to the message being processed
33/// - Pre-parsed function configuration
34/// - Reference to the DataLogic instance for JSONLogic evaluation
35pub trait FunctionHandler: Send + Sync {
36 /// Execute the function on a message with pre-parsed configuration
37 ///
38 /// # Arguments
39 ///
40 /// * `message` - The message to process
41 /// * `config` - Pre-parsed function configuration
42 /// * `datalogic` - Reference to DataLogic instance for JSONLogic evaluation
43 ///
44 /// # Returns
45 ///
46 /// * `Result<(usize, Vec<Change>)>` - Result containing status code and changes, or error
47 fn execute(
48 &self,
49 message: &mut Message,
50 config: &FunctionConfig,
51 datalogic: &DataLogic,
52 ) -> Result<(usize, Vec<Change>)>;
53}