pub struct CheckpointManager {
pub interval_secs: f64,
/* private fields */
}Expand description
Handles saving and loading crawler checkpoints to disk.
You do not create this directly; the CrawlerEngine
manages it internally. It writes to <crawldir>/checkpoint.json and
supports configurable save intervals so you can trade off between
checkpoint frequency and disk I/O overhead.
Fields§
§interval_secs: f64The minimum interval in seconds between automatic checkpoint saves.
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(crawldir: impl Into<PathBuf>, interval_secs: f64) -> Result<Self>
pub fn new(crawldir: impl Into<PathBuf>, interval_secs: f64) -> Result<Self>
Creates a new checkpoint manager writing to the given directory.
interval_secs controls how often the engine auto-saves during the
crawl loop. A value of 0.0 disables periodic saves (checkpoints are
still taken on pause). Returns an error if interval_secs is negative.
Sourcepub fn has_checkpoint(&self) -> bool
pub fn has_checkpoint(&self) -> bool
Returns true if a checkpoint file exists on disk. The engine checks
this at startup to decide whether to resume from a previous run or start
fresh.
Sourcepub fn save(&self, data: &CheckpointData) -> Result<()>
pub fn save(&self, data: &CheckpointData) -> Result<()>
Atomically writes checkpoint data to disk using a temporary file and rename. The two-step write ensures that a crash during serialization cannot corrupt an existing checkpoint. The crawl directory is created automatically if it does not exist.
Sourcepub fn load(&self) -> Result<Option<CheckpointData>>
pub fn load(&self) -> Result<Option<CheckpointData>>
Loads checkpoint data from disk, returning None if no checkpoint
exists. If the file exists but cannot be deserialized (e.g., it was
corrupted), a warning is logged and None is returned rather than
propagating an error, so the crawl can start fresh.
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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