diff --git a/src/arguments.rs b/src/arguments.rs
index ed075b7..4174f51 100644
--- a/src/arguments.rs
+++ b/src/arguments.rs
@@ -1,7 +1,8 @@
use clap::Parser;
const NOTIFICATION_TIMEOUT: u8 = 5;
-const NOTIFICATION_BODY: &str = "Playing: {title} from {album} \n\n Artist: {artist} - {year}";
+const NOTIFICATION_BODY: &str =
+ "Playing: {title} from {album} \n\n Artist: {artist} - {year}";
const NOTIFICATION_SUMMARY: &str = "{artist} - {title}";
const NOTIFICATION_APP_NAME: &str = "C* Music Player";
const DEFAULT_MAX_DEPTH: u8 = 3;
diff --git a/src/cmus/mod.rs b/src/cmus/mod.rs
index 5f28396..cc1fbef 100644
--- a/src/cmus/mod.rs
+++ b/src/cmus/mod.rs
@@ -34,7 +34,7 @@ pub enum CmusError {
EmptyPath,
DurationError(String),
PositionError(String),
- UnknownError(String)
+ UnknownError(String),
}
impl Display for CmusError {
@@ -75,21 +75,43 @@ impl FromStr for Track {
fn from_str(s: &str) -> Result {
let mut lines = s.lines();
- Ok(Track::builder().status(
- TrackStatus::from_str(lines.next().ok_or(CmusError::NoStatus)?.split_once(' ')
- .ok_or(CmusError::NoStatus)?.1)?
- )
- .path(lines.next().ok_or(CmusError::EmptyPath)?.split_once(' ')
- .ok_or(CmusError::EmptyPath)?.1.to_string())
+ Ok(Track::builder()
+ .status(TrackStatus::from_str(
+ lines
+ .next()
+ .ok_or(CmusError::NoStatus)?
+ .split_once(' ')
+ .ok_or(CmusError::NoStatus)?
+ .1,
+ )?)
+ .path(
+ lines
+ .next()
+ .ok_or(CmusError::EmptyPath)?
+ .split_once(' ')
+ .ok_or(CmusError::EmptyPath)?
+ .1
+ .to_string(),
+ )
.duration(
- lines.next().ok_or(CmusError::DurationError("Missing duration".to_string()))?.split_once(' ')
- .ok_or(CmusError::DurationError("Empty duration".to_string()))?.1.parse()
- .map_err(|e: ParseIntError| CmusError::DurationError(e.to_string()))?
+ lines
+ .next()
+ .ok_or(CmusError::DurationError("Missing duration".to_string()))?
+ .split_once(' ')
+ .ok_or(CmusError::DurationError("Empty duration".to_string()))?
+ .1
+ .parse()
+ .map_err(|e: ParseIntError| CmusError::DurationError(e.to_string()))?,
)
.position(
- lines.next().ok_or(CmusError::PositionError("Missing position".to_string()))?.split_once(' ')
- .ok_or(CmusError::PositionError("Empty position".to_string()))?.1.parse()
- .map_err(|e: ParseIntError| CmusError::PositionError(e.to_string()))?
+ lines
+ .next()
+ .ok_or(CmusError::PositionError("Missing position".to_string()))?
+ .split_once(' ')
+ .ok_or(CmusError::PositionError("Empty position".to_string()))?
+ .1
+ .parse()
+ .map_err(|e: ParseIntError| CmusError::PositionError(e.to_string()))?,
)
.metadata(TrackMetadata::parse(lines))
.build())
@@ -101,7 +123,7 @@ impl TrackMetadata {
/// This function will assume you processed the first 4 lines, and remove them from the iterator.
///
/// and also assume the all tags is contained in the iterator.
- fn parse<'a>(mut lines: impl Iterator- ) -> Self {
+ fn parse<'a>(mut lines: impl Iterator
- ) -> Self {
let mut tags = HashMap::new();
while let Some(line) = lines.next() {
@@ -129,8 +151,15 @@ impl Track {
///
/// This is the title, if it exists, otherwise it's the file name without the extension.
pub fn get_name(&self) -> &str {
- self.metadata.get("title").unwrap_or_else(|| self.path.split('/').last()
- .unwrap_or("").split_once(".").unwrap_or(("", "")).0)
+ self.metadata.get("title").unwrap_or_else(|| {
+ self.path
+ .split('/')
+ .last()
+ .unwrap_or("")
+ .split_once(".")
+ .unwrap_or(("", ""))
+ .0
+ })
}
}
@@ -140,14 +169,18 @@ impl Track {
#[inline]
pub fn get_track(query_command: &mut std::process::Command) -> Result