Compare commits
2 commits
8d506131ca
...
3fd546f632
Author | SHA1 | Date | |
---|---|---|---|
3fd546f632 | |||
eb86c20e35 |
2 changed files with 25 additions and 6 deletions
|
@ -36,7 +36,7 @@ impl std::ops::Deref for FileSystem {
|
|||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
Self::Real(fs) => fs,
|
||||
Self::Temp(fs) => fs.deref(),
|
||||
Self::Temp(fs) => fs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
@ -19,10 +22,26 @@ pub struct TempFileSystem {
|
|||
_temp_dir: Arc<Mutex<TempDir>>,
|
||||
}
|
||||
|
||||
impl std::ops::Deref for TempFileSystem {
|
||||
type Target = dyn super::FileSystemLike;
|
||||
impl super::FileSystemLike for TempFileSystem {
|
||||
fn base(&self) -> &Path {
|
||||
self.real.base()
|
||||
}
|
||||
fn path_of(&self, path: PathBuf) -> super::Result<PathBuf> {
|
||||
self.real.path_of(path)
|
||||
}
|
||||
fn file_write(&self, path: &Path, contents: &str) -> super::Result<()> {
|
||||
self.real.file_write(path, contents)
|
||||
}
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.real
|
||||
fn file_read_to_string(&self, path: &Path) -> super::Result<String> {
|
||||
self.real.file_read_to_string(path)
|
||||
}
|
||||
|
||||
fn path_exists(&self, path: &Path) -> super::Result<bool> {
|
||||
self.real.path_exists(path)
|
||||
}
|
||||
|
||||
fn path_is_file(&self, path: &Path) -> super::Result<bool> {
|
||||
self.real.path_is_file(path)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue