willdo 0.0.1

Task manager with DAG
Documentation
//! Job graph abstraction

use super::{commander::Commander, progress::ProgressTracker};
use crate::job::{Job, JobId};
use std::sync::Arc;

/// A built [JobRepository] knows the job graph and can decide which jobs are required and which jobs can be executed.
pub trait JobRepository {
    /// Get a list of jobs ready to run for the goals
    fn execute(&mut self, goals: &[Box<str>]) -> Vec<Execution>;
    /// Get a list of jobs required to satisfy the oals
    fn select(&self, goals: &[Box<str>]) -> Vec<JobId>;
}
impl<T: JobRepository> JobRepository for &mut T {
    fn execute(&mut self, goals: &[Box<str>]) -> Vec<Execution> {
        T::execute(self, goals)
    }
    fn select(&self, goals: &[Box<str>]) -> Vec<JobId> {
        T::select(self, goals)
    }
}

/// A scheduled job instance
#[derive(Debug, Clone)]
pub struct Execution {
    job: Arc<Job>,
    commander: Arc<dyn Commander + Send + Sync>,
    progress: Arc<dyn ProgressTracker + Send + Sync>,
}
impl Execution {
    /// Create a new job exectuion
    pub fn new(
        job: Arc<Job>,
        commander: Arc<dyn Commander + Send + Sync>,
        progress: Arc<dyn ProgressTracker + Send + Sync>,
    ) -> Self {
        Self {
            job,
            commander,
            progress,
        }
    }
    /// Get executed job
    pub fn job(&self) -> &Job {
        &self.job
    }
    /// Get assigned commander
    pub fn commander(&self) -> &dyn Commander {
        self.commander.as_ref()
    }
    /// Get assigned progress tracker
    pub fn progress(&self) -> &dyn ProgressTracker {
        self.progress.as_ref()
    }
}