pub struct CheckpointManager {
pub base_dir: String,
pub max_checkpoints: usize,
/* private fields */
}Expand description
Manages a rolling window of simulation checkpoints stored in memory.
In a real deployment base_dir would name a directory on disk; here the
data is kept in an internal HashMap so the module has no I/O dependency.
Fields§
§base_dir: StringBase directory for checkpoint files (informational, not used for in-memory store).
max_checkpoints: usizeMaximum number of checkpoints to retain.
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(base_dir: impl Into<String>, max_checkpoints: usize) -> Self
pub fn new(base_dir: impl Into<String>, max_checkpoints: usize) -> Self
Create a new manager for base_dir retaining at most max_checkpoints.
Sourcepub fn save_checkpoint(&mut self, step: usize, data: &[f64]) -> String
pub fn save_checkpoint(&mut self, step: usize, data: &[f64]) -> String
Save a checkpoint for step, returning the logical path string.
Sourcepub fn list_checkpoints(&self) -> Vec<usize>
pub fn list_checkpoints(&self) -> Vec<usize>
Return all checkpoint step numbers in ascending order.
Sourcepub fn load_checkpoint(&self, step: usize) -> Option<Vec<f64>>
pub fn load_checkpoint(&self, step: usize) -> Option<Vec<f64>>
Load the data for step, or None if no such checkpoint exists.
Sourcepub fn cleanup_old(&mut self)
pub fn cleanup_old(&mut self)
Remove old checkpoints so that at most max_checkpoints are kept.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CheckpointManager
impl RefUnwindSafe for CheckpointManager
impl Send for CheckpointManager
impl Sync for CheckpointManager
impl Unpin for CheckpointManager
impl UnsafeUnpin for CheckpointManager
impl UnwindSafe for CheckpointManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.