diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 9a49d5d..17402f4 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -1,35 +1,16 @@ use std::path::PathBuf; -use derive_more::From; - mod real; +mod result; mod temp; mod dir_item; pub use dir_item::DirItem; pub use dir_item::DirItemIterator; use real::FileSystem; +pub use result::*; use temp::TempFileSystem; -#[derive(Debug, From, derive_more::Display)] -pub enum Error { - Io(std::io::Error), - - #[display("Path access attempted outside of base ({base:?}): {path:?}")] - PathTraversal { - base: PathBuf, - path: PathBuf, - }, - - #[display("Path must be a directory: {path:?}")] - NotADirectory { - path: PathBuf, - }, -} -impl std::error::Error for Error {} - -pub type Result = core::result::Result; - pub const fn new(base: PathBuf) -> FileSystem { real::new(base) } diff --git a/src/fs/result.rs b/src/fs/result.rs new file mode 100644 index 0000000..9e3e679 --- /dev/null +++ b/src/fs/result.rs @@ -0,0 +1,23 @@ +// +use std::path::PathBuf; + +use derive_more::From; + +#[derive(Debug, From, derive_more::Display)] +pub enum Error { + Io(std::io::Error), + + #[display("Path access attempted outside of base ({base:?}): {path:?}")] + PathTraversal { + base: PathBuf, + path: PathBuf, + }, + + #[display("Path must be a directory: {path:?}")] + NotADirectory { + path: PathBuf, + }, +} +impl std::error::Error for Error {} + +pub type Result = core::result::Result;