// License: see LICENSE file at root directory of `master` branch

//! # Tasks

mod db_manager;
mod request_handler;
mod request_verifier;
mod response_sender;

use blackhole::Job;

pub use db_manager::*;
pub use request_handler::*;
pub use request_verifier::*;
pub use response_sender::*;

/// # Tasks
pub enum Task {

    /// # Database manager
    DbManager(DbManager),

    /// # Request verifier
    RequestVerifier(RequestVerifier),

}

impl Job for Task {

    fn run(&mut self) -> Option<Box<dyn Job>> {
        match self {
            Task::DbManager(db_manager) => if let Err(err) = db_manager.run() {
                __e!("DbManager failed: {:?}", err);
            },
            Task::RequestVerifier(request_verifier) => return request_verifier.run(),
        };

        None
    }

}
