amico_lib/impls/
action_selector_impl.rs

1use crate::actions::PrintAction;
2use amico_core::entities::Event;
3use amico_core::traits::{Action, ActionSelector};
4use std::thread;
5use std::time::Duration;
6
7/// Implementation of the ActionSelector trait.
8#[derive(Default)]
9pub struct ActionSelectorImpl;
10
11impl ActionSelector for ActionSelectorImpl {
12    fn select_action(&self, events: Vec<Event>) -> (Box<dyn Action>, Vec<u32>) {
13        println!("events: {:?}", events);
14        if !events.is_empty() {
15            // Simulate some processing time
16            thread::sleep(Duration::from_millis(200));
17            (
18                Box::new(PrintAction::new("Executing actions".to_string())),
19                events.iter().map(|event| event.id).collect(),
20            )
21        } else {
22            (
23                Box::new(PrintAction::new("No events available".to_string())),
24                vec![],
25            )
26        }
27    }
28}