From 86990efcf8fa63decb05f462d745b95e4992dc77 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Thu, 11 Mar 2021 20:15:47 -0800 Subject: 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. --- src/path/error.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/path/error.rs') 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 = std::result::Result; + + #[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)), } } } -- cgit 1.4.1