diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 0000000..30bab2a
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4222f97..1af07c1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,8 +3,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/src/cmus/events.rs b/src/cmus/events.rs
new file mode 100644
index 0000000..adf6163
--- /dev/null
+++ b/src/cmus/events.rs
@@ -0,0 +1,12 @@
+use crate::cmus::player_settings::AAAMode;
+use crate::cmus::TrackStatus;
+
+pub enum CmusEvent {
+ StatusChanged(TrackStatus),
+ TrackChanged,
+ VolumeChanged { left: u8, right: u8 },
+ PositionChanged(u32),
+ ShuffleChanged(bool),
+ RepeatChanged(bool),
+ AAAMode(AAAMode),
+}
diff --git a/src/cmus/mod.rs b/src/cmus/mod.rs
index cc1fbef..000a768 100644
--- a/src/cmus/mod.rs
+++ b/src/cmus/mod.rs
@@ -1,8 +1,13 @@
+mod events;
+mod query;
+mod player_settings;
+
use std::collections::HashMap;
use std::fmt::Display;
use std::num::ParseIntError;
use std::str::FromStr;
use typed_builder::TypedBuilder;
+use crate::cmus::query::CmusQueryResponse;
#[derive(Debug, PartialEq, Default)]
pub struct TrackMetadata {
@@ -26,7 +31,7 @@ pub struct Track {
pub position: u32,
}
-#[derive(Debug)]
+#[derive(Debug, PartialEq)]
pub enum CmusError {
CmusRunningError(String),
UnknownStatus,
@@ -35,6 +40,8 @@ pub enum CmusError {
DurationError(String),
PositionError(String),
UnknownError(String),
+ UnknownAAAMode(String),
+ UnknownShuffleMode(String),
}
impl Display for CmusError {
@@ -47,6 +54,8 @@ impl Display for CmusError {
CmusError::DurationError(s) => write!(f, "Duration error: {}", s),
CmusError::PositionError(s) => write!(f, "Position error: {}", s),
CmusError::UnknownError(s) => write!(f, "Unknown error: {}", s),
+ CmusError::UnknownAAAMode(s) => write!(f, "Unknown AAA mode: {}", s),
+ CmusError::UnknownShuffleMode(s) => write!(f, "Unknown shuffle mode: {}", s),
}
}
}
@@ -164,10 +173,10 @@ impl Track {
}
/// Make a status request to cmus.
-/// And collect the output, and parse it into a `Track`.
+/// And collect the output, and parse it into a `CmusQueryResponse`.
/// If the cmus is not running, or the socket is not available, this function will return an error.
#[inline]
-pub fn get_track(query_command: &mut std::process::Command) -> Result