summary refs log tree commit diff stats
path: root/src/strcursor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/strcursor.rs')
-rw-r--r--src/strcursor.rs32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/strcursor.rs b/src/strcursor.rs
index b9bf626..d733ade 100644
--- a/src/strcursor.rs
+++ b/src/strcursor.rs
@@ -8,29 +8,7 @@
 use ::std::io::Cursor;
 use ::std::str::FromStr;
 
-/// Built-in `StringReader` errors.
-pub trait ReadError<'a, C: StringReader<'a>>: Sized + std::error::Error {
-    /// Creates an error that indicates an invalid integer was found.
-    fn invalid_integer(context: &C, from: &str) -> Self;
-    /// Creates an error that indicates an integer was expected.
-    fn expected_integer(context: &C) -> Self;
-    /// Creates an error that indicates an invalid float was found.
-    fn invalid_float(context: &C, from: &str) -> Self;
-    /// Creates an error that indicates a float was expected.
-    fn expected_float(context: &C) -> Self;
-    /// Creates an error that indicates an invalid bool was found.
-    fn invalid_bool(context: &C, from: &str) -> Self;
-    /// Creates an error that indicates a bool was expected.
-    fn expected_bool(context: &C) -> Self;
-    /// Creates an error that indicates the start of a quote was expected.
-    fn expected_start_of_quote(context: &C) -> Self;
-    /// Creates an error that indicates the end of a quote was expected.
-    fn expected_end_of_quote(context: &C) -> Self;
-    /// Creates an error that indicates an invalid escape was found.
-    fn invalid_escape(context: &C, from: &str) -> Self;
-    /// Creates an error that indicates a symbol was expected.
-    fn expected_symbol(context: &C, from: &str) -> Self;
-}
+use crate::error::ReadError;
 
 /// Extension trait on [`Cursor`]s to help with command parsing.
 ///
@@ -130,14 +108,14 @@ pub trait StringReader<'a>: Sized {
     ///
     /// Panics if this cursor is not on an UTF-8 character boundary.
     fn read_integer<T, E: ReadError<'a, Self>>(&mut self) -> Result<T, E>
-    where T: FromStr<Err=std::num::ParseIntError>;
+    where T: FromStr<Err=::std::num::ParseIntError>;
     /// Reads a float.
     ///
     /// # Panics
     ///
     /// Panics if this cursor is not on an UTF-8 character boundary.
     fn read_float<T, E: ReadError<'a, Self>>(&mut self) -> Result<T, E>
-    where T: FromStr<Err=std::num::ParseFloatError>;
+    where T: FromStr<Err=::std::num::ParseFloatError>;
     /// Reads a bool.
     ///
     /// # Panics
@@ -202,7 +180,7 @@ impl<'a> StringReader<'a> for Cursor<&'a str> {
     }
 
     fn read_integer<T, E: ReadError<'a, Self>>(&mut self) -> Result<T, E>
-    where T: FromStr<Err=std::num::ParseIntError> {
+    where T: FromStr<Err=::std::num::ParseIntError> {
         // see read_unquoted_str for rationale
         let start = self.position() as usize;
         let total = self.get_ref().len();
@@ -223,7 +201,7 @@ impl<'a> StringReader<'a> for Cursor<&'a str> {
         }
     }
     fn read_float<T, E: ReadError<'a, Self>>(&mut self) -> Result<T, E>
-    where T: FromStr<Err=std::num::ParseFloatError> {
+    where T: FromStr<Err=::std::num::ParseFloatError> {
         // see read_unquoted_str for rationale
         let start = self.position() as usize;
         let total = self.get_ref().len();