Skip to main content

odx_core/
fs.rs

1use std::io;
2use std::path::Path;
3
4/// Minimal file system access used by the odx library crates.
5pub trait FileSystem: std::fmt::Debug + Send + Sync {
6    /// Read the whole file at `path`.
7    ///
8    /// # Errors
9    ///
10    /// Returns an error when the file does not exist or cannot be read.
11    fn read(&self, path: &Path) -> io::Result<Vec<u8>>;
12
13    /// Create or replace the file at `path` with `contents`.
14    ///
15    /// # Errors
16    ///
17    /// Returns an error when the file cannot be written.
18    fn write(&self, path: &Path, contents: &[u8]) -> io::Result<()>;
19
20    /// Whether a file or directory exists at `path`.
21    fn exists(&self, path: &Path) -> bool;
22}