pub struct ProgressThrottle {
last_emit: Option<Instant>,
min_interval: Duration,
}Expand description
Rate-limiter for progress updates.
Ensures progress events are not emitted more frequently than the configured interval.
Fields§
§last_emit: Option<Instant>§min_interval: DurationImplementations§
Source§impl ProgressThrottle
impl ProgressThrottle
Sourcepub const fn new(min_interval: Duration) -> Self
pub const fn new(min_interval: Duration) -> Self
Create a new throttle with the specified minimum interval.
Sourcepub const fn default_interval() -> Self
pub const fn default_interval() -> Self
Create a throttle with a default interval of 100ms.
Sourcepub fn should_emit(&mut self) -> bool
pub fn should_emit(&mut self) -> bool
Check if enough time has passed to emit another progress update.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProgressThrottle
impl RefUnwindSafe for ProgressThrottle
impl Send for ProgressThrottle
impl Sync for ProgressThrottle
impl Unpin for ProgressThrottle
impl UnsafeUnpin for ProgressThrottle
impl UnwindSafe for ProgressThrottle
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