feat(fs): extract fs::like internal module

This commit is contained in:
Paul Campbell 2024-04-28 12:37:15 +01:00
parent 483d274e5b
commit 9c76ddc3e1
2 changed files with 16 additions and 9 deletions

12
src/fs/like.rs Normal file
View file

@ -0,0 +1,12 @@
use super::Result;
use std::path::{Path, PathBuf};
pub trait FileSystemLike {
fn base(&self) -> &Path;
fn path_of(&self, path: PathBuf) -> Result<PathBuf>;
fn file_write(&self, path: &Path, contents: &str) -> Result<()>;
fn file_read_to_string(&self, path: &Path) -> Result<String>;
fn path_exists(&self, path: &Path) -> Result<bool>;
fn path_is_file(&self, path: &Path) -> Result<bool>;
}

View file

@ -1,7 +1,10 @@
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use derive_more::From;
use crate::fs::like::FileSystemLike;
mod like;
mod real;
mod temp;
@ -40,11 +43,3 @@ impl std::ops::Deref for FileSystem {
}
}
}
pub trait FileSystemLike {
fn base(&self) -> &Path;
fn path_of(&self, path: PathBuf) -> Result<PathBuf>;
fn file_write(&self, path: &Path, contents: &str) -> Result<()>;
fn file_read_to_string(&self, path: &Path) -> Result<String>;
fn path_exists(&self, path: &Path) -> Result<bool>;
fn path_is_file(&self, path: &Path) -> Result<bool>;
}