let spotify_match_map = arc_locked_xset_map.clone();
let _ = spotify_proxy.match_signal(
move |pc: PropertiesPropertiesChanged, _: &Connection, _: &Message| {
- pc.changed_properties["Metadata"]
- .0
- .as_iter()
- .and_then(|mut iter| {
- // Iterating over a RefArg goes key, value, key, value... Insane honestly.
- while let Some(key) = iter.next() {
- let key_str = key.as_str()?;
- let value = iter.next();
+ match pc.changed_properties.get("Metadata") {
+ Some(variant) => {
+ variant.0.as_iter().and_then(|mut iter| {
+ // Iterating over a RefArg goes key, value, key, value... Insane honestly.
+ while let Some(key) = iter.next() {
+ let key_str = key.as_str()?;
+ let value = iter.next();
- match key_str {
- "xesam:artist" => {
- // Variant holding a variant that should just be a Vec<&str> I
- // believe. This is _the recommended_ way to do this by the author.
- let inner_value = value?.as_iter()?.next()?.as_iter()?.next()?;
- let artist = inner_value.as_str()?;
- update_map(spotify_match_map.clone(), "artist", artist);
+ match key_str {
+ "xesam:artist" => {
+ // Variant holding a variant that should just be a Vec<&str> I
+ // believe. This is _the recommended_ way to do this by the author.
+ let inner_value =
+ value?.as_iter()?.next()?.as_iter()?.next()?;
+ let artist = inner_value.as_str()?;
+ update_map(spotify_match_map.clone(), "artist", artist);
+ }
+ "xesam:title" => {
+ let title = value?.as_iter()?.next()?.as_str()?;
+ update_map(spotify_match_map.clone(), "title", title);
+ }
+ _ => (),
}
- "xesam:title" => {
- let title = value?.as_iter()?.next()?.as_str()?;
- update_map(spotify_match_map.clone(), "title", title);
- }
- _ => (),
}
- }
- Some(())
- });
- let playback_status = &pc.changed_properties["PlaybackStatus"].0;
- update_map(
- spotify_match_map.clone(),
- "playback_status",
- match &*playback_status.as_str().unwrap_or("") {
- "Playing" => "🔊",
- _ => "🔈",
- },
- );
+ Some(())
+ });
+ }
+ None => (),
+ }
+ match &pc.changed_properties.get("PlaybackStatus") {
+ Some(variant) => {
+ let playback_status = &variant.0;
+ update_map(
+ spotify_match_map.clone(),
+ "playback_status",
+ match &*playback_status.as_str().unwrap_or("") {
+ "Playing" => "🔊",
+ _ => "🔈",
+ },
+ );
+ }
+ None => (),
+ }
true
},
);