diff options
Diffstat (limited to 'src/utils/mpd.rs')
-rw-r--r-- | src/utils/mpd.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/utils/mpd.rs b/src/utils/mpd.rs index b7fdbd6..3752387 100644 --- a/src/utils/mpd.rs +++ b/src/utils/mpd.rs @@ -1,21 +1,22 @@ use crate::config::CONFIG; +use crate::types::ThreadsData; use mpd::{Client, Song}; // yes, error handling looks fucking sucks! // getting mpd song file -pub fn get_mpd_current() -> String { +pub fn get_mpd_current() -> ThreadsData { let stream_path = format!("{}:{}", CONFIG.mpd.host, CONFIG.mpd.port); - let empty_string = String::from(""); + let empty_data = ThreadsData::Mpd(String::from("")); let mut conn = match Client::connect(&stream_path) { Ok(connection) => connection, - _ => return empty_string, + _ => return empty_data, }; let current: Song = match conn.currentsong() { Ok(opt) => match opt { Some(song) => song, - _ => return empty_string, + _ => return empty_data, }, - _ => return empty_string, + _ => return empty_data, }; let result = format!( @@ -23,5 +24,5 @@ pub fn get_mpd_current() -> String { CONFIG.mpd.icon, current.file, CONFIG.seperator ); - result + ThreadsData::Mpd(result) } |