Skip to main content

ProgressState

Struct ProgressState 

Source
pub struct ProgressState<'a, F>
where F: ProgressCallback + ?Sized,
{ /* private fields */ }
Expand description

Helper wrapper for throttling progress callback frequency.

Some operations progress very quickly (e.g., processing thousands of items), and reporting progress on every item would overwhelm the callback and impact performance. This wrapper enforces a minimum time between updates.

§Example

use sqlitegraph::progress::{ProgressCallback, ProgressState, NoProgress};
use std::time::Duration;

let inner = NoProgress;
let mut progress = ProgressState::new(&inner, Duration::from_millis(100));

// Only reports if at least 100ms has passed since last report
progress.update(5, Some(10), "Processing")?;
progress.update(6, Some(10), "Processing")?; // May be skipped

Implementations§

Source§

impl<'a, F> ProgressState<'a, F>
where F: ProgressCallback + ?Sized,

Source

pub fn new(callback: &'a F, interval: Duration) -> Self

Creates a new progress state wrapper.

§Parameters
  • callback: The underlying progress callback to wrap
  • interval: Minimum time between progress updates
§Example
use sqlitegraph::progress::{ProgressCallback, ProgressState, NoProgress};
use std::time::Duration;

let callback = NoProgress;
let progress = ProgressState::new(&callback, Duration::from_millis(100));
Source

pub fn update(&mut self, current: usize, total: Option<usize>, message: &str)

Updates progress, but only if the minimum interval has elapsed.

§Parameters
  • current: Current step or item being processed
  • total: Total number of steps (if known)
  • message: Human-readable progress message
§Example
// Returns immediately if interval hasn't elapsed
progress.update(50, Some(100), "Processing");
Source

pub fn force_update( &mut self, current: usize, total: Option<usize>, message: &str, )

Forces an immediate progress update, bypassing the throttling logic.

Use this for important milestones (e.g., completion) that should always be reported regardless of timing.

§Example
// Always report the final update, even if interval hasn't elapsed
progress.force_update(100, Some(100), "Complete");
Source

pub fn update_interval(&self) -> Duration

Returns the configured update interval.

§Example
let interval = progress.update_interval();
assert_eq!(interval, Duration::from_millis(100));

Trait Implementations§

Source§

impl<'a, F> Debug for ProgressState<'a, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, F> !Freeze for ProgressState<'a, F>

§

impl<'a, F> RefUnwindSafe for ProgressState<'a, F>
where F: RefUnwindSafe + ?Sized,

§

impl<'a, F> Send for ProgressState<'a, F>
where F: ?Sized,

§

impl<'a, F> Sync for ProgressState<'a, F>
where F: ?Sized,

§

impl<'a, F> Unpin for ProgressState<'a, F>
where F: ?Sized,

§

impl<'a, F> UnwindSafe for ProgressState<'a, F>
where F: RefUnwindSafe + ?Sized,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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