MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / truncate_from

Method truncate_from

atomic-remote/src/sync.rs:207–213  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Calls 2

getMethod · 0.65
cloneMethod · 0.45