mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
implement setters
This commit is contained in:
parent
7c4451e46f
commit
f9885713cc
2 changed files with 42 additions and 6 deletions
28
src/model.rs
28
src/model.rs
|
|
@ -128,24 +128,52 @@ impl Entry {
|
|||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_artist (&mut self, value: &impl AsRef<str> ) {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref mut artist, .. } => *artist = Some(value.as_ref().into()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn album (&self) -> Option<Arc<str>> {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref album, .. } => album.clone(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_album (&mut self, value: &impl AsRef<str> ) {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref mut album, .. } => *album = Some(value.as_ref().into()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn title (&self) -> Option<Arc<str>> {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref title, .. } => title.clone(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_title (&mut self, value: &impl AsRef<str> ) {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref mut title, .. } => *title = Some(value.as_ref().into()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn track (&self) -> Option<Arc<str>> {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref track, .. } => track.map(|t|format!("{t}").into()).clone(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_track (&mut self, value: &impl AsRef<str> ) {
|
||||
match self.info {
|
||||
EntryInfo::Music { ref mut track, .. } => {
|
||||
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
|
||||
*track = Some(value)
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl EntryInfo {
|
||||
pub fn new (path: &Path) -> Usually<Self> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue