pub struct StateStore { /* private fields */ }Expand description
State store for resumable sync progress.
Implementations§
Source§impl StateStore
impl StateStore
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Open or create the sync state store.
Examples found in repository?
examples/stats.rs (line 29)
8fn main() -> Result<()> {
9 let args: Vec<String> = env::args().collect();
10 if args.len() != 2 {
11 eprintln!("Usage: stats <dataset_path>");
12 std::process::exit(1);
13 }
14
15 let base_path = std::path::Path::new(&args[1]);
16
17 println!("=== LSH Index ===");
18 let lsh_path = base_path.join("lsh.redb");
19 if lsh_path.exists() {
20 let lsh = DiskLSH::open(&lsh_path)?;
21 println!(" Documents: {}", lsh.count()?);
22 } else {
23 println!(" NOT FOUND");
24 }
25
26 println!("\n=== Sync State ===");
27 let state_path = base_path.join("state.redb");
28 if state_path.exists() {
29 let state = StateStore::open(&state_path)?;
30 let progress = state.get_sync_progress()?;
31 println!(" Step: {:?}", progress.step);
32 println!(
33 " Dupes: {}/{}",
34 progress.dupes_written, progress.dupes_total
35 );
36 println!(
37 " Parents: {}/{}",
38 progress.parents_marked, progress.parents_total
39 );
40 println!(
41 " Children: {}/{}",
42 progress.children_marked, progress.children_total
43 );
44 } else {
45 println!(" NOT FOUND");
46 }
47
48 println!("\n=== Match Store ===");
49 let match_path = base_path.join("matches.redb");
50 if match_path.exists() {
51 let matches = MatchStore::open(&match_path)?;
52 println!(" Total matches: {}", matches.count()?);
53 } else {
54 println!(" NOT FOUND");
55 }
56
57 Ok(())
58}Sourcepub fn get_sync_progress(&self) -> Result<SyncProgress>
pub fn get_sync_progress(&self) -> Result<SyncProgress>
Get current sync progress
Examples found in repository?
examples/stats.rs (line 30)
8fn main() -> Result<()> {
9 let args: Vec<String> = env::args().collect();
10 if args.len() != 2 {
11 eprintln!("Usage: stats <dataset_path>");
12 std::process::exit(1);
13 }
14
15 let base_path = std::path::Path::new(&args[1]);
16
17 println!("=== LSH Index ===");
18 let lsh_path = base_path.join("lsh.redb");
19 if lsh_path.exists() {
20 let lsh = DiskLSH::open(&lsh_path)?;
21 println!(" Documents: {}", lsh.count()?);
22 } else {
23 println!(" NOT FOUND");
24 }
25
26 println!("\n=== Sync State ===");
27 let state_path = base_path.join("state.redb");
28 if state_path.exists() {
29 let state = StateStore::open(&state_path)?;
30 let progress = state.get_sync_progress()?;
31 println!(" Step: {:?}", progress.step);
32 println!(
33 " Dupes: {}/{}",
34 progress.dupes_written, progress.dupes_total
35 );
36 println!(
37 " Parents: {}/{}",
38 progress.parents_marked, progress.parents_total
39 );
40 println!(
41 " Children: {}/{}",
42 progress.children_marked, progress.children_total
43 );
44 } else {
45 println!(" NOT FOUND");
46 }
47
48 println!("\n=== Match Store ===");
49 let match_path = base_path.join("matches.redb");
50 if match_path.exists() {
51 let matches = MatchStore::open(&match_path)?;
52 println!(" Total matches: {}", matches.count()?);
53 } else {
54 println!(" NOT FOUND");
55 }
56
57 Ok(())
58}Sourcepub fn set_sync_progress(&self, progress: &SyncProgress) -> Result<()>
pub fn set_sync_progress(&self, progress: &SyncProgress) -> Result<()>
Set sync progress atomically
Sourcepub fn update_sync_field(&self, field: &str, value: u64) -> Result<()>
pub fn update_sync_field(&self, field: &str, value: u64) -> Result<()>
Update a single sync progress field (for incremental updates)
Sourcepub fn reset_sync_progress(&self) -> Result<()>
pub fn reset_sync_progress(&self) -> Result<()>
Reset sync progress (for fresh start)
Sourcepub fn is_sync_in_progress(&self) -> Result<bool>
pub fn is_sync_in_progress(&self) -> Result<bool>
Check if sync is in progress (started but not completed)
Sourcepub fn is_sync_completed(&self) -> Result<bool>
pub fn is_sync_completed(&self) -> Result<bool>
Check if sync is completed
Auto Trait Implementations§
impl !RefUnwindSafe for StateStore
impl !UnwindSafe for StateStore
impl Forget for StateStore
impl Freeze for StateStore
impl Move for StateStore
impl Send for StateStore
impl Sync for StateStore
impl Unpin for StateStore
impl UnsafeUnpin for StateStore
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> 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> ⓘ
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