diff --git a/src/model.rs b/src/model.rs index 117d332..9d53010 100644 --- a/src/model.rs +++ b/src/model.rs @@ -18,14 +18,14 @@ pub struct Taggart { pub editing: Option<(usize, String)>, } -#[derive(Ord, Eq, PartialEq, PartialOrd)] +#[derive(Ord, Eq, PartialEq, PartialOrd, Debug)] pub struct Entry { pub path: PathBuf, pub depth: usize, pub info: EntryInfo, } -#[derive(Ord, Eq, PartialEq, PartialOrd)] +#[derive(Ord, Eq, PartialEq, PartialOrd, Debug)] pub enum EntryInfo { Directory { hash_file: Option<()>, @@ -128,44 +128,48 @@ impl Entry { _ => None } } - pub fn set_artist (&mut self, value: &impl AsRef ) { - match self.info { - EntryInfo::Music { ref mut artist, .. } => *artist = Some(value.as_ref().into()), - _ => {} - } - } pub fn album (&self) -> Option> { match self.info { EntryInfo::Music { ref album, .. } => album.clone(), _ => None } } - pub fn set_album (&mut self, value: &impl AsRef ) { - match self.info { - EntryInfo::Music { ref mut album, .. } => *album = Some(value.as_ref().into()), - _ => {} - } - } pub fn title (&self) -> Option> { match self.info { EntryInfo::Music { ref title, .. } => title.clone(), _ => None } } - pub fn set_title (&mut self, value: &impl AsRef ) { - match self.info { - EntryInfo::Music { ref mut title, .. } => *title = Some(value.as_ref().into()), - _ => {} - } - } pub fn track (&self) -> Option> { match self.info { EntryInfo::Music { ref track, .. } => track.map(|t|format!("{t}").into()).clone(), _ => None } } + pub fn set_artist (&mut self, value: &impl AsRef ) { + match self.info { + EntryInfo::Directory { .. } => todo!("set artist for whole directory"), + EntryInfo::Music { ref mut artist, .. } => *artist = Some(value.as_ref().into()), + _ => {} + } + } + pub fn set_album (&mut self, value: &impl AsRef ) { + match self.info { + EntryInfo::Directory { .. } => todo!("set album for whole directory"), + EntryInfo::Music { ref mut album, .. } => *album = Some(value.as_ref().into()), + _ => {} + } + } + pub fn set_title (&mut self, value: &impl AsRef ) { + match self.info { + EntryInfo::Directory { .. } => todo!("set title for whole directory"), + EntryInfo::Music { ref mut title, .. } => *title = Some(value.as_ref().into()), + _ => {} + } + } pub fn set_track (&mut self, value: &impl AsRef ) { match self.info { + EntryInfo::Directory { .. } => todo!("set track for whole directory"), EntryInfo::Music { ref mut track, .. } => { if let Ok(value) = value.as_ref().trim().parse::() { *track = Some(value)