1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// org id jgSEtEI/xIjz/bF+vtGtYbEA9bNIeFWLqnZT+M51S64=
use crate::pristine::InodeMetadata;

#[cfg(feature = "ondisk-repos")]
pub mod filesystem;
#[cfg(feature = "ondisk-repos")]
pub use filesystem::FileSystem;

pub mod memory;
pub use memory::Memory;

pub trait WorkingCopy {
    fn create_dir_all(&mut self, path: &str) -> Result<(), anyhow::Error>;
    fn file_metadata(&self, file: &str) -> Result<InodeMetadata, anyhow::Error>;
    fn read_file(&self, file: &str, buffer: &mut Vec<u8>) -> Result<(), anyhow::Error>;
    fn modified_time(&self, file: &str) -> Result<std::time::SystemTime, anyhow::Error>;
    fn remove_path(&mut self, name: &str) -> Result<(), anyhow::Error>;
    fn rename(&mut self, former: &str, new: &str) -> Result<(), anyhow::Error>;
    fn set_permissions(&mut self, name: &str, permissions: u16) -> Result<(), anyhow::Error>;
    fn write_file<A, F: FnOnce(&mut dyn std::io::Write) -> Result<A, anyhow::Error>>(
        &mut self,
        file: &str,
        writer: F,
    ) -> Result<A, anyhow::Error>;
}