Run rustfmt on the entire crate

This commit is contained in:
Emmanuel Gil Peyrot
2019-06-19 00:51:11 +02:00
parent 2911b9bb49
commit b0a62f25eb
4 changed files with 116 additions and 139 deletions

View File

@@ -1,5 +1,5 @@
use env_logger;
use mpvipc::{Mpv, Error as MpvError};
use mpvipc::{Error as MpvError, Mpv};
fn main() -> Result<(), MpvError> {
env_logger::init();

View File

@@ -1,11 +1,5 @@
use env_logger;
use mpvipc::{
Error,
Event,
Mpv,
MpvDataType,
Property,
};
use mpvipc::{Error, Event, Mpv, MpvDataType, Property};
use std::io::{self, Write};
fn seconds_to_hms(total: f64) -> String {
@@ -32,39 +26,47 @@ fn main() -> Result<(), Error> {
loop {
let event = mpv.event_listen()?;
match event {
Event::PropertyChange(property) => {
match property {
Property::Path(Some(value)) => println!("\nPlaying: {}", value),
Property::Path(None) => (),
Property::Pause(value) => pause = value,
Property::PlaybackTime(Some(value)) => playback_time = value,
Property::PlaybackTime(None) => playback_time = std::f64::NAN,
Property::Duration(Some(value)) => duration = value,
Property::Duration(None) => duration = std::f64::NAN,
Property::Metadata(Some(value)) => {
println!("File tags:");
if let Some(MpvDataType::String(value)) = value.get("ARTIST") {
println!(" Artist: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("ALBUM") {
println!(" Album: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("TITLE") {
println!(" Title: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("TRACK") {
println!(" Track: {}", value);
}
},
Property::Metadata(None) => (),
Property::Unknown { name: _, id: _, data: _ } => (),
Event::PropertyChange(property) => match property {
Property::Path(Some(value)) => println!("\nPlaying: {}", value),
Property::Path(None) => (),
Property::Pause(value) => pause = value,
Property::PlaybackTime(Some(value)) => playback_time = value,
Property::PlaybackTime(None) => playback_time = std::f64::NAN,
Property::Duration(Some(value)) => duration = value,
Property::Duration(None) => duration = std::f64::NAN,
Property::Metadata(Some(value)) => {
println!("File tags:");
if let Some(MpvDataType::String(value)) = value.get("ARTIST") {
println!(" Artist: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("ALBUM") {
println!(" Album: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("TITLE") {
println!(" Title: {}", value);
}
if let Some(MpvDataType::String(value)) = value.get("TRACK") {
println!(" Track: {}", value);
}
}
Property::Metadata(None) => (),
Property::Unknown {
name: _,
id: _,
data: _,
} => (),
},
Event::Shutdown => return Ok(()),
Event::Unimplemented => panic!("Unimplemented event"),
_ => (),
}
print!("{}{} / {} ({:.0}%)\r", if pause { "(Paused) " } else { "" }, seconds_to_hms(playback_time), seconds_to_hms(duration), 100. * playback_time / duration);
print!(
"{}{} / {} ({:.0}%)\r",
if pause { "(Paused) " } else { "" },
seconds_to_hms(playback_time),
seconds_to_hms(duration),
100. * playback_time / duration
);
io::stdout().flush().unwrap();
}
}