Add `NoEvents` error for `CmusQueryResponse`

This commit is contained in:
Anas Elgarhy 2023-02-20 05:41:01 +02:00
parent 6d62c66b5f
commit 4773c1c1cd
No known key found for this signature in database
GPG Key ID: 0501802A1D496528
3 changed files with 3 additions and 7 deletions

View File

@ -54,6 +54,8 @@ pub enum CmusError {
UnknownAAAMode(String),
#[error("Unknown shuffle mode: {0}")]
UnknownShuffleMode(String),
#[error("No events")]
NoEvents,
}
impl FromStr for TrackStatus {

View File

@ -51,7 +51,7 @@ impl CmusQueryResponse {
if self.track_row.is_empty() || self.player_settings_row.is_empty() {
#[cfg(feature = "debug")]
info!("Cmus response is empty, returning empty events");
return Ok(Vec::new());
return Err(CmusError::NoEvents)
}
let mut events = Vec::new();

View File

@ -30,12 +30,6 @@ impl NotificationsHandler {
events: Vec<CmusEvent>,
response: &CmusQueryResponse,
) -> Result<(), notify_rust::error::Error> {
if events.is_empty() {
#[cfg(feature = "debug")]
info!("no events to process");
return Ok(()); // No events to process.
}
//FIXME: Should check if the user has enabled the cover feature or use a static cover.
self.update_cover(&events[0], response);