diff --git a/Cargo.lock b/Cargo.lock index c0773b1..2e04779 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1427,7 +1427,7 @@ dependencies = [ [[package]] name = "mpd_info_screen" -version = "0.2.3" +version = "0.2.4" dependencies = [ "ggez", "image", diff --git a/Cargo.toml b/Cargo.toml index a6e5d8c..2321829 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mpd_info_screen" -version = "0.2.3" +version = "0.2.4" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index f81efa6..def6bac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ counter, and the filename currently being played # Usage - mpd_info_screen 0.2.3 + mpd_info_screen 0.2.4 USAGE: mpd_info_screen [FLAGS] [OPTIONS] [port] diff --git a/src/display.rs b/src/display.rs index d03886c..d59d01f 100644 --- a/src/display.rs +++ b/src/display.rs @@ -186,6 +186,12 @@ impl MPDDisplay { .try_read() .map_err(|_| String::from("ERROR get_image_from_data: Failed to get read_handle"))?; + if !read_handle.is_art_data_ready() { + return Err(String::from( + "ERROR get_image_from_data: art data not ready", + )); + } + let mut image_format: image::ImageFormat = image::ImageFormat::Png; match read_handle.get_art_type().as_str() { "image/png" => image_format = image::ImageFormat::Png, diff --git a/src/mpd_handler.rs b/src/mpd_handler.rs index 364dbc8..ffec118 100644 --- a/src/mpd_handler.rs +++ b/src/mpd_handler.rs @@ -318,6 +318,10 @@ impl MPDHandler { self.art_data_type.clone() } + pub fn is_art_data_ready(&self) -> bool { + self.art_data.len() == self.art_data_size + } + pub fn get_art_data(&self) -> &[u8] { &self.art_data }