diff options
author | Irene Knapp <ireneista@gmail.com> | 2021-03-11 20:15:47 -0800 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2021-03-11 20:15:47 -0800 |
commit | 86990efcf8fa63decb05f462d745b95e4992dc77 (patch) | |
tree | 46990fd1c749ccca0b6477650973d83174e5e264 /src/path | |
parent | a159d4dd29491a1eb88163e63ceb41a903dc47b6 (diff) |
refactor everything into smaller modules; move to using async-std; make the read loop async. some stuff doesn't work yet but it needed to be done and this is as clean a state as it's likely to get in, so we're committing it as a base to build on.
Diffstat (limited to 'src/path')
-rw-r--r-- | src/path/error.rs | 28 | ||||
-rw-r--r-- | src/path/prelude.rs | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/path/error.rs b/src/path/error.rs index 0ee5423..aee6e9f 100644 --- a/src/path/error.rs +++ b/src/path/error.rs @@ -1,3 +1,10 @@ +#![forbid(unsafe_code)] + +use crate::path::GenericPath; + +pub type Result<T> = std::result::Result<T, PathError>; + + #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] pub enum FileNameError { ContainsSlash(String), @@ -11,6 +18,10 @@ pub enum DirectoryNameError { #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] pub enum PathError { Parse(String), + PathLexicallyDirectory(GenericPath), + PathLexicallyRelative(GenericPath), + PathLexicallyInvalid(GenericPath), + PathListHasEmptyComponents(String), } @@ -45,6 +56,23 @@ impl std::fmt::Display for PathError { match self { PathError::Parse(s) => f.write_fmt(format_args!("Syntax error in path: {}", s)), + PathError::PathLexicallyDirectory(path) => + f.write_fmt(format_args!( + "The path {} ends in a slash, but is supposed to refer to a file, \ + not a directory.", + path)), + PathError::PathLexicallyRelative(path) => + f.write_fmt(format_args!( + "The path {} is relative, not absolute.", + path)), + PathError::PathLexicallyInvalid(path) => + f.write_fmt(format_args!( + "This isn't a valid path. {}", + path)), + PathError::PathListHasEmptyComponents(path_list) => + f.write_fmt(format_args!( + "Path list has empty components: {}", + path_list)), } } } diff --git a/src/path/prelude.rs b/src/path/prelude.rs new file mode 100644 index 0000000..f7b23dd --- /dev/null +++ b/src/path/prelude.rs @@ -0,0 +1,5 @@ +#![forbid(unsafe_code)] + +pub use crate::path::error::{ + Result, DirectoryNameError, FileNameError, PathError}; + |