pub struct CheckpointManager {
pub directory: PathBuf,
pub base_name: String,
pub format: CheckpointFormat,
pub keep_n: usize,
pub interval: usize,
/* private fields */
}Expand description
Checkpoint manager for automatic saving
Fields§
§directory: PathBufDirectory for checkpoint files
base_name: StringBase filename for checkpoints
format: CheckpointFormatSerialization format
keep_n: usizeHow many checkpoints to keep
interval: usizeSave interval (generations)
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(directory: impl Into<PathBuf>, base_name: impl Into<String>) -> Self
pub fn new(directory: impl Into<PathBuf>, base_name: impl Into<String>) -> Self
Create a new checkpoint manager
Sourcepub fn with_format(self, format: CheckpointFormat) -> Self
pub fn with_format(self, format: CheckpointFormat) -> Self
Set the serialization format
Sourcepub fn should_save(&self, generation: usize) -> bool
pub fn should_save(&self, generation: usize) -> bool
Check if a checkpoint should be saved at this generation
Sourcepub fn current_path(&self) -> PathBuf
pub fn current_path(&self) -> PathBuf
Get the path for the current checkpoint
Sourcepub fn save<G>(
&mut self,
checkpoint: &Checkpoint<G>,
) -> Result<(), CheckpointError>
pub fn save<G>( &mut self, checkpoint: &Checkpoint<G>, ) -> Result<(), CheckpointError>
Save a checkpoint and rotate old ones
Sourcepub fn load_latest<G>(&self) -> Result<Option<Checkpoint<G>>, CheckpointError>
pub fn load_latest<G>(&self) -> Result<Option<Checkpoint<G>>, CheckpointError>
Find and load the latest checkpoint
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.