Skip to main content

StateStore

Struct StateStore 

Source
pub struct StateStore { /* private fields */ }
Expand description

State store for resumable sync progress.

Implementations§

Source§

impl StateStore

Source

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}
Source

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}
Source

pub fn set_sync_progress(&self, progress: &SyncProgress) -> Result<()>

Set sync progress atomically

Source

pub fn update_sync_field(&self, field: &str, value: u64) -> Result<()>

Update a single sync progress field (for incremental updates)

Source

pub fn reset_sync_progress(&self) -> Result<()>

Reset sync progress (for fresh start)

Source

pub fn is_sync_in_progress(&self) -> Result<bool>

Check if sync is in progress (started but not completed)

Source

pub fn is_sync_completed(&self) -> Result<bool>

Check if sync is completed

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more