use async_trait::async_trait;
use tracing::instrument;
use cellos_core::ports::{CellBackend, CellHandle, TeardownReport};
use cellos_core::{CellosError, ExecutionCellDocument};
pub struct StubCellBackend;
#[async_trait]
impl CellBackend for StubCellBackend {
#[instrument(skip(self, spec))]
async fn create(&self, spec: &ExecutionCellDocument) -> Result<CellHandle, CellosError> {
if spec.spec.id.is_empty() {
return Err(CellosError::InvalidSpec("spec.id must be non-empty".into()));
}
Ok(CellHandle {
cell_id: spec.spec.id.clone(),
cgroup_path: None,
nft_rules_applied: None,
kernel_digest_sha256: None,
rootfs_digest_sha256: None,
firecracker_digest_sha256: None,
})
}
#[instrument(skip(self, handle))]
async fn destroy(&self, handle: &CellHandle) -> Result<TeardownReport, CellosError> {
Ok(TeardownReport {
cell_id: handle.cell_id.clone(),
destroyed: true,
peers_tracked_after: 0,
})
}
}