Built-in Functions Overview
Dataflow-rs comes with built-in action functions for common data processing tasks, covering the complete lifecycle from parsing input to publishing output.
Available Functions
| Function | Purpose | Modifies Data |
|---|---|---|
parse_json | Parse JSON from payload into data context | Yes |
parse_xml | Parse XML string into JSON data structure | Yes |
map | Data transformation and field mapping | Yes |
validation | Rule-based data validation | No (read-only) |
filter | Pipeline control flow — halt workflow or skip task | No |
log | Structured logging with JSONLogic expressions | No |
publish_json | Serialize data to JSON string | Yes |
publish_xml | Serialize data to XML string | Yes |
Common Patterns
Complete Pipeline: Parse → Transform → Validate → Publish
{
"tasks": [
{
"id": "parse_input",
"function": {
"name": "parse_json",
"input": {
"source": "payload",
"target": "input"
}
}
},
{
"id": "transform",
"function": {
"name": "map",
"input": {
"mappings": [
{"path": "data.user.fullName", "logic": {"cat": [{"var": "data.input.firstName"}, " ", {"var": "data.input.lastName"}]}}
]
}
}
},
{
"id": "validate",
"function": {
"name": "validation",
"input": {
"rules": [
{"logic": {"!!": {"var": "data.user.fullName"}}, "message": "Full name required"}
]
}
}
},
{
"id": "publish",
"function": {
"name": "publish_json",
"input": {
"source": "user",
"target": "response",
"pretty": true
}
}
}
]
}
Conditional Transformation
{
"tasks": [
{
"id": "conditional_map",
"condition": {"==": [{"var": "data.tier"}, "premium"]},
"function": {
"name": "map",
"input": {
"mappings": [
{"path": "data.discount", "logic": 20}
]
}
}
}
]
}
XML Processing Pipeline
{
"tasks": [
{
"id": "parse_xml_input",
"function": {
"name": "parse_xml",
"input": {
"source": "payload",
"target": "xmlData"
}
}
},
{
"id": "transform",
"function": {
"name": "map",
"input": {
"mappings": [
{"path": "data.response.status", "logic": "processed"}
]
}
}
},
{
"id": "publish_xml_output",
"function": {
"name": "publish_xml",
"input": {
"source": "response",
"target": "xmlOutput",
"root_element": "Response"
}
}
}
]
}
Function Configuration
All functions use this structure:
{
"function": {
"name": "function_name",
"input": {
// Function-specific configuration
}
}
}
Custom Functions
For operations beyond built-in functions, implement the AsyncFunctionHandler trait. See Custom Functions.
Learn More
- Parse Functions - JSON and XML parsing
- Map Function - Data transformation
- Validation Function - Rule-based validation
- Filter Function - Pipeline control flow (halt/skip)
- Log Function - Structured logging
- Publish Functions - JSON and XML serialization