aboutsummaryrefslogtreecommitdiff
path: root/src/queue.rs
blob: 821c508c9e31aa124ec087d2225c32149642fe30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use mpd::Song;

#[derive(Debug)]
pub struct Queue {
    pub list: Vec<Song>,
    pub index: usize,
}

impl Queue {
    pub fn new() -> Self {
        Queue {
            list: Vec::new(),
            index: 0,
        }
    }

    // Go to next item in list
    pub fn next(&mut self) {
        let len = self.list.len();
        if len != 0 {
            if self.index < len - 1 {
                self.index += 1;
            }
        }
    }

    /// Go to previous item in list
    pub fn prev(&mut self) {
        if self.index != 0 {
            self.index -= 1;
        }
    }

    pub fn reset_index(&mut self) {
        self.index = 0;
    }
}