pub mod memory;
pub mod sandbox;
pub mod state;
pub mod storage;
pub use memory::MemoryBackend;
pub use sandbox::SandboxedFsBackend;
pub use state::{InMemoryStateBackend, StateBackend};
pub use storage::{Blob, InMemoryStorageBackend, LocalFsStorageBackend, StorageBackend};
use async_trait::async_trait;
use cognis_core::Result;
#[async_trait]
pub trait Backend: Send + Sync {
async fn read(&self, path: &str) -> Result<String>;
async fn write(&self, path: &str, contents: &str) -> Result<()>;
async fn edit(
&self,
path: &str,
find: &str,
replace: &str,
max_occurrences: usize,
) -> Result<usize>;
async fn ls(&self, dir: &str) -> Result<Vec<String>>;
async fn glob(&self, pattern: &str) -> Result<Vec<String>>;
async fn grep(&self, pattern: &str) -> Result<Vec<GrepHit>>;
async fn exists(&self, path: &str) -> Result<bool>;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GrepHit {
pub path: String,
pub line: u64,
pub text: String,
}