perf(http): use custom type for ParseEof error instead of string error
This commit is contained in:
		| @@ -72,7 +72,8 @@ impl<T: AsyncRead + AsyncWrite> Buffered<T> { | |||||||
|             match self.read_from_io() { |             match self.read_from_io() { | ||||||
|                 Ok(0) => { |                 Ok(0) => { | ||||||
|                     trace!("parse eof"); |                     trace!("parse eof"); | ||||||
|                     return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "parse eof").into()); |                     //TODO: With Rust 1.14, this can be Error::from(ErrorKind) | ||||||
|  |                     return Err(io::Error::new(io::ErrorKind::UnexpectedEof, ParseEof).into()); | ||||||
|                 } |                 } | ||||||
|                 Ok(_) => {}, |                 Ok(_) => {}, | ||||||
|                 Err(e) => match e.kind() { |                 Err(e) => match e.kind() { | ||||||
| @@ -316,6 +317,21 @@ impl WriteBuf { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[derive(Debug)] | ||||||
|  | struct ParseEof; | ||||||
|  |  | ||||||
|  | impl fmt::Display for ParseEof { | ||||||
|  |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|  |         f.write_str("parse eof") | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | impl ::std::error::Error for ParseEof { | ||||||
|  |     fn description(&self) -> &str { | ||||||
|  |         "parse eof" | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| use std::io::Read; | use std::io::Read; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user