Introduce a file access interface for reading additional files.
This commit is contained in:
13
src/context/file_access_interface.rs
Normal file
13
src/context/file_access_interface.rs
Normal 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)?)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user