1
//! The id counter of a window's requests: only the latest one is awaited.
2

            
3
#[derive(Clone, Copy, Debug, Default)]
4
pub struct Seq(u64);
5

            
6
impl Seq {
7
    /// Starts a request; an older one stops being awaited.
8
1658
    pub fn advance(&mut self) -> u64 {
9
1658
        self.0 = self.0.wrapping_add(1);
10
1658
        self.0
11
1658
    }
12

            
13
    #[must_use]
14
10
    pub fn current(&self) -> u64 {
15
10
        self.0
16
10
    }
17

            
18
    #[must_use]
19
713
    pub fn awaits(&self, id: u64) -> bool {
20
713
        self.0 == id
21
713
    }
22
}
23

            
24
#[cfg(test)]
25
mod tests;