fluxus_transformers/operator/
mod.rs

1use async_trait::async_trait;
2use fluxus_utils::models::{Record, StreamResult};
3
4mod builder;
5mod filter;
6mod map;
7mod window_match;
8mod window_reduce;
9
10pub use builder::OperatorBuilder;
11pub use filter::FilterOperator;
12pub use map::MapOperator;
13pub use window_match::{WindowAllOperator, WindowAnyOperator};
14pub use window_reduce::WindowReduceOperator;
15
16/// Operator trait defines the interface for stream processing operators
17#[async_trait]
18pub trait Operator<In, Out>: Send {
19    /// Initialize the operator
20    async fn init(&mut self) -> StreamResult<()> {
21        Ok(())
22    }
23
24    /// Process a single record and return zero or more output records
25    async fn process(&mut self, record: Record<In>) -> StreamResult<Vec<Record<Out>>>;
26
27    /// Called when a window is triggered (if windowing is enabled)
28    async fn on_window_trigger(&mut self) -> StreamResult<Vec<Record<Out>>> {
29        Ok(Vec::new())
30    }
31
32    /// Close the operator and release resources
33    async fn close(&mut self) -> StreamResult<()> {
34        Ok(())
35    }
36}