Remove all entries at or after a given sequence number. Used when the remote has diverged and we need to discard our stale cache entries.
(&mut self, from_sequence: u64)
| 205 | /// Used when the remote has diverged and we need to discard |
| 206 | /// our stale cache entries. |
| 207 | pub fn truncate_from(&mut self, from_sequence: u64) { |
| 208 | self.entries.retain(|&seq, _| seq < from_sequence); |
| 209 | self.last_sequence = self.entries.keys().copied().max(); |
| 210 | self.last_state = self |
| 211 | .last_sequence |
| 212 | .and_then(|s| self.entries.get(&s).map(|n| n.state.clone())); |
| 213 | } |
| 214 | |
| 215 | /// Clear all cached state. |
| 216 | pub fn clear(&mut self) { |