1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use shiny_jobs::Job;
use std::sync::Arc;

#[derive(Default)]
pub struct JobsController(Vec<(String, Arc<dyn Job>)>);

impl JobsController {
    pub fn new() -> Self {
        JobsController::default()
    }

    pub fn add(&mut self, name: impl ToString, job: impl Job + 'static) -> &mut Self {
        self.0.push((name.to_string(), Arc::new(job)));
        self
    }

    pub fn take_jobs(self) -> Vec<(String, Arc<dyn Job>)> {
        self.0
    }
}