summaryrefslogtreecommitdiff
path: root/racer-tracer/src/image_action.rs
blob: 9156b6da9f49d2ee03d2e0e21bc3ac339a5a70ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pub mod png;
pub mod wait_for_signal;

use std::sync::RwLock;

use slog::Logger;
use synchronoise::SignalEvent;

use crate::image_action::{png::SavePng, wait_for_signal::WaitForSignal};

use crate::terminal::Terminal;
use crate::{
    config::{Config, ImageAction as CImageAction},
    error::TracerError,
};

pub trait ImageAction: Send + Sync {
    fn action(
        &self,
        screen_buffer: &RwLock<Vec<u32>>,
        cancel_event: &SignalEvent,
        event: &SignalEvent,
        config: &Config,
        log: Logger,
        term: &Terminal,
    ) -> Result<(), TracerError>;
}

impl From<&CImageAction> for &dyn ImageAction {
    fn from(image_action: &CImageAction) -> Self {
        match image_action {
            CImageAction::WaitForSignal => &WaitForSignal {} as &dyn ImageAction,
            CImageAction::SavePng => &SavePng {} as &dyn ImageAction,
        }
    }
}