organic/src/context/file_access_interface.rs

16 lines
445 B
Rust
Raw Normal View History

use std::fmt::Debug;
use std::path::Path;
pub trait FileAccessInterface: Debug {
fn read_file(&self, path: &dyn AsRef<Path>) -> Result<String, Box<dyn std::error::Error>>;
}
#[derive(Debug, Clone)]
pub struct LocalFileAccessInterface;
impl FileAccessInterface for LocalFileAccessInterface {
fn read_file(&self, path: &dyn AsRef<Path>) -> Result<String, Box<dyn std::error::Error>> {
Ok(std::fs::read_to_string(path)?)
}
}