playbook_api/systems/
mod.rs

1pub mod docker;
2
3#[cfg(feature = "sys_hotwings")]
4pub mod hotwings;
5
6use ymlctx::context::Context;
7use crate::TaskError;
8
9pub trait Infrastructure {
10    fn start<I>(&self, Context, I) -> Result<String, TaskError>
11      where
12        I: IntoIterator,
13        I::Item: AsRef<std::ffi::OsStr>;
14}
15
16pub fn abstract_infrastructures(name: &str) -> Option<impl Infrastructure> {
17    match name {
18        #[cfg(feature = "sys_hotwings")]
19        "hotwings" => Some(SupportedInfrastructure::Hotwings(hotwings::Hotwings {})),
20        "docker" => Some(SupportedInfrastructure::Docker(docker::Docker {})),
21        _ => None
22    }
23}
24
25pub enum SupportedInfrastructure {
26    Docker(docker::Docker),
27    #[cfg(feature = "sys_hotwings")]
28    Hotwings(hotwings::Hotwings)
29}
30
31impl Infrastructure for SupportedInfrastructure {
32    fn start<I>(&self, ctx_docker: Context, cmd: I) -> Result<String, TaskError>
33      where I: IntoIterator, I::Item: AsRef<std::ffi::OsStr>
34    {
35        match self {
36            SupportedInfrastructure::Docker(i) => i.start(ctx_docker, cmd),
37            #[cfg(feature = "sys_hotwings")]
38            SupportedInfrastructure::Hotwings(i) => i.start(ctx_docker, cmd)
39        }
40    }
41}