Module snapshots
Expand description
See snapshots for the system contract and examples.
Bounded monotonic tick snapshots. Hosts own state and interpolation semantics.
Failed inserts preserve history; rolling eviction removes only the oldest state.
Use SnapshotRing::bracket_checked for presentation queries with an explicit
outcome when the requested time is outside retained history. It borrows states
without allocating, interpolating game data, or silently extrapolating.
use ferravex_engine::snapshots::{SnapshotBracket, SnapshotQueryError, SnapshotRing};
let mut history = SnapshotRing::new(8);
history.push(10, 0.0_f64).unwrap();
history.push(14, 8.0).unwrap();
// Query tick 11 + 0.5 without converting the whole tick to floating point.
let position = match history.bracket_checked(11, 0.5)? {
SnapshotBracket::Between { before: (_, a), after: (_, b), alpha } => {
Some(a + (b - a) * alpha)
}
SnapshotBracket::Exact { snapshot: (_, state) } => Some(*state),
SnapshotBracket::Empty
| SnapshotBracket::BeforeOldest { .. }
| SnapshotBracket::AfterNewest { .. } => None,
};
assert_eq!(position, Some(3.0));Structs§
- Snapshot
Ring - Bounded history of strictly increasing, nonwrapping
u64ticks.
Enums§
- Snapshot
Bracket - Checked placement of a presentation time within retained snapshot history.
- Snapshot
Query Error - Invalid input to
SnapshotRing::bracket_checked.
Type Aliases§
- Snapshot
Ref - Optional tick and borrowed state, used by
SnapshotRing::bracket.