use crate::environment::EnvironmentSpec;
use crate::error::EnvError;
use crate::operator::{Operator, OperatorInput, OperatorOutput};
use async_trait::async_trait;
use std::sync::Arc;
pub struct LocalEnvironment {
operator: Arc<dyn Operator>,
}
impl LocalEnvironment {
pub fn new(operator: Arc<dyn Operator>) -> Self {
Self { operator }
}
}
#[async_trait]
impl crate::environment::Environment for LocalEnvironment {
async fn run(
&self,
input: OperatorInput,
_spec: &EnvironmentSpec,
) -> Result<OperatorOutput, EnvError> {
self.operator
.execute(input)
.await
.map_err(EnvError::OperatorError)
}
}