starlane 0.3.21

Starlane -- An Orchestration and Infrastructure Framework for WebAssembly Components (https://starlane.io) This packaged manages `HyperSpace` which provides infrastructure for `Space` Apis (WebAssembly & external programs meant to provide custom behaviors in Starlane), This package references the `starlane-space` package and reuses of it to run the infrastructure and it also contains mechanisms (Drivers) for extending the Starlane Type system
Documentation
pub mod cli;
pub mod dialect;

use crate::hyperspace::executor::cli::os::CliOsExecutor;
use crate::hyperspace::host::err::HostErr;
use crate::hyperspace::host::Host;
use crate::hyperspace::service::ServiceErr;
use async_trait::async_trait;

#[async_trait]
pub trait Executor
where
    Self::Err: std::error::Error + 'static,
{
    type In;

    type Out;

    type Err;

    async fn execute(&self, args: Self::In) -> Result<Self::Out, Self::Err>;

    fn conf(&self) -> ExeConf;
}

#[derive(Clone)]
pub enum ExeConf {
    Host(Host),
}

impl ExeConf {
    pub fn with_env(&self, key: &str, value: &str) -> Self {
        match self {
            ExeConf::Host(host) => ExeConf::Host(host.with_env(key, value)),
        }
    }

    pub fn env(&self, key: &str) -> Option<&String> {
        match self {
            ExeConf::Host(host) => host.env(key),
        }
    }

    pub fn create<D>(&self) -> Result<D, HostErr>
    where
        D: TryFrom<CliOsExecutor, Error = HostErr>,
    {
        match self {
            ExeConf::Host(host) => Ok(host.create::<D>()?.try_into()?),
        }
    }
}