mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
database: Remove track iterator from medium
This commit is contained in:
parent
3f5f751992
commit
d49be8d3a2
1 changed files with 0 additions and 43 deletions
|
|
@ -60,49 +60,6 @@ struct TrackRow {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator that iterates through all tracks within a medium in order.
|
|
||||||
pub struct TrackIter<'a> {
|
|
||||||
medium: &'a Medium,
|
|
||||||
track_set_index: usize,
|
|
||||||
track_index: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> TrackIter<'a> {
|
|
||||||
/// Create a new iterator that iterates through tracks within the provided medium.
|
|
||||||
fn new(medium: &'a Medium) -> Self {
|
|
||||||
Self {
|
|
||||||
medium,
|
|
||||||
track_set_index: 0,
|
|
||||||
track_index: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Iterator for TrackIter<'a> {
|
|
||||||
type Item = &'a Track;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a Track> {
|
|
||||||
match self.medium.tracks.get(self.track_set_index) {
|
|
||||||
Some(track_set) => {
|
|
||||||
match track_set.tracks.get(self.track_index) {
|
|
||||||
Some(track) => {
|
|
||||||
if self.track_index + 1 < track_set.tracks.len() {
|
|
||||||
self.track_index += 1;
|
|
||||||
} else {
|
|
||||||
self.track_set_index += 1;
|
|
||||||
self.track_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(track)
|
|
||||||
}
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Database {
|
impl Database {
|
||||||
/// Update an existing medium or insert a new one.
|
/// Update an existing medium or insert a new one.
|
||||||
pub fn update_medium(&self, medium: Medium) -> Result<()> {
|
pub fn update_medium(&self, medium: Medium) -> Result<()> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue