From 9c76ddc3e15fcb8da1b82268a4255d68a669ec35 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 28 Apr 2024 12:37:15 +0100 Subject: [PATCH] feat(fs): extract fs::like internal module --- src/fs/like.rs | 12 ++++++++++++ src/fs/mod.rs | 13 ++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 src/fs/like.rs diff --git a/src/fs/like.rs b/src/fs/like.rs new file mode 100644 index 0000000..33e859d --- /dev/null +++ b/src/fs/like.rs @@ -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; + fn file_write(&self, path: &Path, contents: &str) -> Result<()>; + fn file_read_to_string(&self, path: &Path) -> Result; + fn path_exists(&self, path: &Path) -> Result; + fn path_is_file(&self, path: &Path) -> Result; +} diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 56a573f..a030ef9 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -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; - fn file_write(&self, path: &Path, contents: &str) -> Result<()>; - fn file_read_to_string(&self, path: &Path) -> Result; - fn path_exists(&self, path: &Path) -> Result; - fn path_is_file(&self, path: &Path) -> Result; -}