-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Error type + remove refill's stack allocation + bump tokio v…
…ersion (1.0) + rustfmt
- Loading branch information
Showing
4 changed files
with
42 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "minimp3" | ||
version = "0.5.0" | ||
version = "0.5.1" | ||
authors = ["germän gômez <[email protected]>", "Erin Moon <[email protected]>"] | ||
description = "Rust bindings for the minimp3 library." | ||
keywords = ["mp3", "audio", "decoder", "mpeg", "media"] | ||
|
@@ -12,12 +12,13 @@ edition = "2018" | |
[dependencies] | ||
slice-deque = "0.3.0" | ||
minimp3-sys = { version = "0.3", path = "minimp3-sys" } | ||
tokio = { version = "0.2", features = ["io-util"], optional = true } | ||
tokio = { version = "1.0", features = ["io-util"], optional = true } | ||
thiserror = "1.0.23" | ||
|
||
[features] | ||
default = [] | ||
async_tokio = ["tokio"] | ||
|
||
[dev-dependencies] | ||
tokio = {version = "0.2", features = ["full"] } | ||
futures = "0.3.4" | ||
tokio = { version = "1.0", features = ["full"] } | ||
futures = "0.3.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
wrap_comments = true | ||
merge_imports = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,20 @@ | ||
use std::{error::Error as StdError, fmt, io}; | ||
use thiserror::Error; | ||
|
||
/// Errors encountered by the MP3 decoder. | ||
#[derive(Debug)] | ||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("IO error: {0}")] | ||
/// An error caused by some IO operation required during decoding. | ||
Io(io::Error), | ||
/// The decoder tried to parse a frame from its internal buffer, but there was not enough. | ||
Io(#[from] std::io::Error), | ||
#[error("Insufficient data")] | ||
/// The decoder tried to parse a frame from its internal buffer, but there | ||
/// was not enough. | ||
InsufficientData, | ||
/// The decoder encountered data which was not a frame (ie, ID3 data), and skipped it. | ||
#[error("Skipped data")] | ||
/// The decoder encountered data which was not a frame (ie, ID3 data), and | ||
/// skipped it. | ||
SkippedData, | ||
#[error("End of reader")] | ||
/// The decoder has reached the end of the provided reader. | ||
Eof, | ||
} | ||
|
||
impl From<io::Error> for Error { | ||
fn from(err: io::Error) -> Self { | ||
Error::Io(err) | ||
} | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { | ||
match self { | ||
Error::Io(io_err) => write!(f, "IO error: {}", io_err), | ||
_ => f.write_str(self.description()), | ||
} | ||
} | ||
} | ||
|
||
impl StdError for Error { | ||
fn description(&self) -> &str { | ||
match self { | ||
Error::Io(io_err) => io_err.description(), | ||
Error::InsufficientData => "Insufficient data", | ||
Error::SkippedData => "Skipped data", | ||
Error::Eof => "End of reader", | ||
} | ||
} | ||
|
||
fn cause(&self) -> Option<&dyn StdError> { | ||
match self { | ||
Error::Io(io_err) => Some(io_err), | ||
_ => None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters