Compare commits

..

2 commits

Author SHA1 Message Date
3fd546f632 build(justfile): add validate dev branch recipe
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-28 11:24:56 +01:00
eb86c20e35 feat(fs): new fs module to replace filesystem 2024-04-28 11:24:56 +01:00
2 changed files with 25 additions and 6 deletions

View file

@ -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,
}
}
}

View file

@ -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)
}
}