use crate::Error;
use crossbeam::channel::{self, Sender, Receiver};

pub(crate) mod query; pub(crate) use query::{Query, QueryData};

pub(crate) mod supervisor; pub(crate) use supervisor::*;
pub(crate) mod window; pub(crate) use window::*;
pub(crate) mod video; pub(crate) use video::*;
pub(crate) mod audio; pub(crate) use audio::*;
pub(crate) mod input; pub(crate) use input::*;
pub(crate) mod control; pub(crate) use control::*;
pub(crate) mod scene; pub(crate) use scene::*;
pub(crate) mod network; pub(crate) use network::*;
pub(crate) mod storage; pub(crate) use storage::*;
pub(crate) mod api; pub(crate) use api::*;
pub(crate) mod api_control; pub(crate) use api_control::*;
pub(crate) mod api_device; pub(crate) use api_device::*;
pub(crate) mod app; pub(crate) use app::*;

pub(crate) trait Subsystem : From<Sender<Query>> {
    fn start(supervisor:Option<Sender<Query>>) -> Result<Sender<Query>, Error>;
    fn shutdown() -> Result<(), Error> { Ok(()) }
}

#[derive(Clone, Copy)]
pub enum System {
    Supervisor = 0,
    Window,
    Video,
    Audio,
    Input,
    Control,
    Scene,
    Network,
    Storage,
    API,
    APIDevice,
    APIControl,
    App,
    _MAX,
}
