use async_trait::async_trait;
use super::{Capability, ExecutionContext, ExecutionResult, SnapshotId, ValidationResult};
use crate::types::SessionId;
#[async_trait]
pub trait ExecutionEnvironment: Send + Sync {
type Error: std::error::Error + Send + Sync + 'static;
async fn execute_code(
&self,
code: &str,
ctx: &ExecutionContext,
) -> Result<ExecutionResult, Self::Error>;
async fn execute_command(
&self,
cmd: &str,
ctx: &ExecutionContext,
) -> Result<ExecutionResult, Self::Error>;
async fn validate(&self, input: &str) -> Result<ValidationResult, Self::Error>;
async fn create_snapshot(
&self,
session_id: &SessionId,
name: &str,
) -> Result<SnapshotId, Self::Error>;
async fn restore_snapshot(&self, id: &SnapshotId) -> Result<(), Self::Error>;
async fn list_snapshots(&self, session_id: &SessionId) -> Result<Vec<SnapshotId>, Self::Error>;
async fn delete_snapshot(&self, id: &SnapshotId) -> Result<(), Self::Error>;
async fn delete_session_snapshots(&self, session_id: &SessionId) -> Result<(), Self::Error>;
fn capabilities(&self) -> &[Capability];
fn has_capability(&self, capability: Capability) -> bool {
self.capabilities().contains(&capability)
}
fn backend_type(&self) -> crate::config::BackendType;
async fn health_check(&self) -> Result<bool, Self::Error>;
async fn cleanup(&self) -> Result<(), Self::Error>;
async fn end_session(&self, _session_id: &SessionId) -> Result<(), Self::Error> {
Ok(())
}
}