Introduce a file access interface for reading additional files.

This commit is contained in:
Tom Alexander
2023-09-04 13:00:41 -04:00
parent a8f277efe5
commit da1ce2717d
3 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
use std::path::Path;
pub trait FileAccessInterface {
fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<String, Box<dyn std::error::Error>>;
}
pub struct LocalFileAccessInterface;
impl FileAccessInterface for LocalFileAccessInterface {
fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<String, Box<dyn std::error::Error>> {
Ok(std::fs::read_to_string(path)?)
}
}