diff --git a/src/cmus/mod.rs b/src/cmus/mod.rs index 516d93b..c0a67b4 100644 --- a/src/cmus/mod.rs +++ b/src/cmus/mod.rs @@ -15,6 +15,9 @@ use typed_builder::TypedBuilder; pub trait TemplateProcessor { fn process(&self, template: &String) -> String; + + /// Returns a vector of keys found in the template. + /// The keys are the strings between curly braces. fn get_keys(template: &String) -> Vec { let mut keys = Vec::new(); // Just a buffer to store the keys. let mut key = String::new(); // Just a buffer to build the key. @@ -85,6 +88,9 @@ pub enum CmusError { } impl TemplateProcessor for Track { + /// Process the template with the track metadata. + /// The template is a string with placeholders that will be replaced with the track metadata. + /// The unknown placeholders will be skipped (don't replaced with anything, because they are maybe placeholders for player settings). fn process(&self, template: &String) -> String { #[cfg(feature = "debug")] { diff --git a/src/cmus/player_settings.rs b/src/cmus/player_settings.rs index 9aa6556..41efce4 100644 --- a/src/cmus/player_settings.rs +++ b/src/cmus/player_settings.rs @@ -38,6 +38,9 @@ pub enum AAAMode { } impl TemplateProcessor for PlayerSettings { + /// Replace all keys in the template with the corresponding values. + /// If the key is unknown, it will be replaced with an empty string. + /// This function should be used after the track metadata placeholders have been replaced. fn process(&self, template: &String) -> String { #[cfg(feature = "debug")] { diff --git a/src/cmus/query.rs b/src/cmus/query.rs index e66b8d2..5288cb1 100644 --- a/src/cmus/query.rs +++ b/src/cmus/query.rs @@ -44,6 +44,7 @@ impl CmusQueryResponse { PlayerSettings::from_str(&self.player_settings_row) } + /// Compare this response with another one, and return the events that happened. pub fn events(&self, other: &Self) -> Result, CmusError> { #[cfg(feature = "debug")] info!("Comparing cmus responses: {:?} and {:?}", self, other);