use std::path::Path;
use async_trait::async_trait;
use crate::error::Result;
#[async_trait]
pub trait ClientIo: Send + Sync {
async fn read_file(&self, path: &Path) -> Option<Result<String>>;
async fn write_file(&self, path: &Path, content: &str) -> Option<Result<()>>;
}
pub struct NoClientIo;
#[async_trait]
impl ClientIo for NoClientIo {
async fn read_file(&self, _path: &Path) -> Option<Result<String>> {
None
}
async fn write_file(&self, _path: &Path, _content: &str) -> Option<Result<()>> {
None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn no_client_io_always_defers_to_local() {
assert!(NoClientIo.read_file(Path::new("/tmp/x")).await.is_none());
assert!(
NoClientIo
.write_file(Path::new("/tmp/x"), "hi")
.await
.is_none()
);
}
}