use crate::{send_command, Command};
macro_rules! send_command {
($self:expr,$command:expr) => {{
if $self.is_info_some() {
send_command($command)
} else {
false
}
}};
}
pub trait Controller {
fn is_info_some(&self) -> bool;
fn toggle(&self) -> bool {
send_command!(self, Command::TogglePlayPause)
}
fn play(&self) -> bool {
send_command!(self, Command::Play)
}
fn pause(&self) -> bool {
send_command!(self, Command::Pause)
}
fn next(&self) -> bool {
send_command!(self, Command::NextTrack)
}
fn previous(&self) -> bool {
send_command!(self, Command::PreviousTrack)
}
}