pub mod definitions;
pub mod responses;
mod command_list;
use std::borrow::Cow;
use std::time::Duration;
use mpd_protocol::command::Argument;
use crate::raw::RawCommand;
use responses::Response;
pub use command_list::CommandList;
pub use definitions::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SongId(pub u64);
impl From<u64> for SongId {
fn from(id: u64) -> Self {
Self(id)
}
}
impl Argument for SongId {
fn render(self) -> Cow<'static, str> {
Cow::Owned(self.0.to_string())
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SongPosition(pub usize);
impl From<usize> for SongPosition {
fn from(pos: usize) -> Self {
Self(pos)
}
}
impl Argument for SongPosition {
fn render(self) -> Cow<'static, str> {
Cow::Owned(self.0.to_string())
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SeekMode {
Forward(Duration),
Backward(Duration),
Absolute(Duration),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(missing_docs)]
pub enum SingleMode {
Enabled,
Disabled,
Oneshot,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Song {
Id(SongId),
Position(SongPosition),
}
impl From<SongId> for Song {
fn from(id: SongId) -> Self {
Self::Id(id)
}
}
impl From<SongPosition> for Song {
fn from(pos: SongPosition) -> Self {
Self::Position(pos)
}
}
pub trait Command {
type Response: Response;
fn to_command(self) -> RawCommand;
}