pub struct ResumableBatchGenerator { /* private fields */ }Expand description
Resumable batch generator with checkpoint support.
This generator can save progress and resume from where it left off, useful for generating very large batches of keys.
§Example
use rustywallet_batch::checkpoint::ResumableBatchGenerator;
use rustywallet_batch::mmap::OutputFormat;
// Start or resume generation
let mut generator = ResumableBatchGenerator::new(
"my-job",
1_000_000,
"keys.txt",
"checkpoint.json",
);
generator.generate_with_progress(|progress| {
println!("Progress: {:.1}%", progress);
}).unwrap();Implementations§
Source§impl ResumableBatchGenerator
impl ResumableBatchGenerator
Sourcepub fn new(
job_id: &str,
total_count: usize,
output_path: &str,
checkpoint_path: &str,
) -> Self
pub fn new( job_id: &str, total_count: usize, output_path: &str, checkpoint_path: &str, ) -> Self
Create a new resumable generator.
If a checkpoint exists, it will be loaded and generation will resume.
Sourcepub fn new_incremental(
job_id: &str,
total_count: usize,
output_path: &str,
checkpoint_path: &str,
start_key: &str,
) -> Self
pub fn new_incremental( job_id: &str, total_count: usize, output_path: &str, checkpoint_path: &str, start_key: &str, ) -> Self
Create a new resumable generator for incremental mode.
Sourcepub fn chunk_size(self, size: usize) -> Self
pub fn chunk_size(self, size: usize) -> Self
Set the chunk size for generation.
Sourcepub fn checkpoint_interval(self, interval: usize) -> Self
pub fn checkpoint_interval(self, interval: usize) -> Self
Set the checkpoint interval.
Sourcepub fn progress(&self) -> &Checkpoint
pub fn progress(&self) -> &Checkpoint
Get current progress.
Sourcepub fn generate_with_progress<F>(
&mut self,
progress_callback: F,
) -> Result<usize, BatchError>
pub fn generate_with_progress<F>( &mut self, progress_callback: F, ) -> Result<usize, BatchError>
Generate keys with progress callback.
Sourcepub fn generate(&mut self) -> Result<usize, BatchError>
pub fn generate(&mut self) -> Result<usize, BatchError>
Generate keys without progress callback.
Sourcepub fn cleanup(&self) -> Result<(), BatchError>
pub fn cleanup(&self) -> Result<(), BatchError>
Clean up checkpoint file after successful completion.
Auto Trait Implementations§
impl Freeze for ResumableBatchGenerator
impl RefUnwindSafe for ResumableBatchGenerator
impl Send for ResumableBatchGenerator
impl Sync for ResumableBatchGenerator
impl Unpin for ResumableBatchGenerator
impl UnwindSafe for ResumableBatchGenerator
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