use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct RepoView {
pub root: PathBuf,
}
pub struct World {
pub repo: RepoView,
pub runner: Arc<dyn ProcessRunner>,
pub clock: Arc<dyn Clock>,
pub kv: Arc<dyn KvStore>,
}
#[async_trait]
pub trait ProcessRunner: Send + Sync + 'static {
async fn exec(&self, program: &str, args: &[&str], cwd: Option<&Path>) -> std::io::Result<ProcessOutput>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProcessOutput {
pub status: i32,
pub stdout: String,
pub stderr: String,
}
pub trait Clock: Send + Sync + 'static {
fn now_ms(&self) -> i64;
}
#[async_trait]
pub trait KvStore: Send + Sync + 'static {
async fn get(&self, key: &str) -> Option<Vec<u8>>;
async fn set(&self, key: &str, value: Vec<u8>);
async fn delete(&self, key: &str);
}