renamed ParseError::IOError
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
- __Breaking changes:__
|
||||
- Replaced the simple `Strains` struct with a new struct `{Mode}Strains` that contains more detail w.r.t. the mode.
|
||||
- Renamed all `GameMode` variants to more idiomatic names
|
||||
- Renamed `ParseError::IOError` to `ParseError::IoError`
|
||||
|
||||
# v0.6.0 (2022-07-05)
|
||||
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
error::Error as StdError,
|
||||
fmt,
|
||||
io::Error as IOError,
|
||||
io::Error as IoError,
|
||||
num::{ParseFloatError, ParseIntError},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ pub type ParseResult<T> = Result<T, ParseError>;
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum ParseError {
|
||||
/// Some IO operation failed.
|
||||
IOError(IOError),
|
||||
IoError(IoError),
|
||||
/// The initial data of an `.osu` file was incorrect.
|
||||
IncorrectFileHeader,
|
||||
/// Line in `.osu` was unexpectedly not of the form `key:value`.
|
||||
@@ -37,7 +37,7 @@ pub enum ParseError {
|
||||
impl fmt::Display for ParseError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::IOError(_) => f.write_str("IO error"),
|
||||
Self::IoError(_) => f.write_str("IO error"),
|
||||
Self::IncorrectFileHeader => {
|
||||
write!(f, "expected `osu file format v` at file begin")
|
||||
}
|
||||
@@ -56,7 +56,7 @@ impl fmt::Display for ParseError {
|
||||
impl StdError for ParseError {
|
||||
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||
match self {
|
||||
Self::IOError(inner) => Some(inner),
|
||||
Self::IoError(inner) => Some(inner),
|
||||
Self::IncorrectFileHeader => None,
|
||||
Self::BadLine => None,
|
||||
Self::InvalidCurvePoints => None,
|
||||
@@ -70,9 +70,9 @@ impl StdError for ParseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IOError> for ParseError {
|
||||
fn from(other: IOError) -> Self {
|
||||
Self::IOError(other)
|
||||
impl From<IoError> for ParseError {
|
||||
fn from(other: IoError) -> Self {
|
||||
Self::IoError(other)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ impl<R> FileReader<R> {
|
||||
/// Parse the buffer into a string, returning `None` if the UTF-8 validation fails.
|
||||
pub(crate) fn get_line(&self) -> Result<&str, ParseError> {
|
||||
std::str::from_utf8(&self.buf)
|
||||
.map_err(|e| ParseError::IOError(IoError::new(IoErrorKind::InvalidData, Box::new(e))))
|
||||
.map_err(|e| ParseError::IoError(IoError::new(IoErrorKind::InvalidData, Box::new(e))))
|
||||
}
|
||||
|
||||
/// Split the buffer at the first ':', then parse the second half into a string.
|
||||
|
||||
Reference in New Issue
Block a user