Skip to main content

wisp/view/
generation.rs

1//! A monotonic marker for cache invalidation.
2
3/// A cache-invalidation marker: bumped when the underlying data changes,
4/// compared by caches to notice they are stale.
5#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
6pub struct Generation(u64);
7
8impl Generation {
9    /// Moves this marker on, invalidating everything built against the old one.
10    pub fn bump(&mut self) {
11        self.0 = self.0.wrapping_add(1);
12    }
13}