remotia_core/processors/containers/
sequential.rs1use async_trait::async_trait;
2use log::debug;
3
4use crate::{
5 pipeline::{feeder::PipelineFeeder, Pipeline},
6 traits::FrameProcessor,
7};
8
9pub struct Sequential<F> {
10 processors: Vec<Box<dyn FrameProcessor<F> + Send>>,
11}
12
13impl<F> Sequential<F> {
14 pub fn new() -> Self {
15 Self {
16 processors: Vec::new(),
17 }
18 }
19
20 pub fn append<T: 'static + FrameProcessor<F> + Send>(mut self, processor: T) -> Self {
21 self.processors.push(Box::new(processor));
22 self
23 }
24}
25
26#[async_trait]
27impl<F: Send> FrameProcessor<F> for Sequential<F> {
28 async fn process(&mut self, frame_data: F) -> Option<F> {
29 let mut result: Option<F> = Some(frame_data);
30
31 for processor in &mut self.processors {
32 if result.is_none() {
33 break;
34 }
35 result = processor.process(result.unwrap()).await;
36 }
37
38 result
39 }
40}