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