pub struct ProgressThrottle {
pub last_emitted_at_ms: i64,
pub last_emitted_bytes: u64,
}Expand description
Tracks when the last progress event was emitted so emit_progress can
apply the 250 ms / 256 KB throttle.
Instantiate one ProgressThrottle per transfer at the start of the stream
loop and pass it mutably to each emit_progress call.
Fields§
§last_emitted_at_ms: i64Millisecond timestamp of the last emitted event (0 = never).
last_emitted_bytes: u64transferred_bytes value at the time of the last emitted event.
Implementations§
Source§impl ProgressThrottle
impl ProgressThrottle
Sourcepub fn should_emit(&self, now_ms: i64, bytes_done: u64) -> bool
pub fn should_emit(&self, now_ms: i64, bytes_done: u64) -> bool
Returns true when a progress event should be emitted now.
The gate opens when:
- no event has been emitted yet (
last_emitted_at_ms == 0), OR - at least 250 ms have elapsed since the last emission, OR
- at least 256 KB more have been transferred since the last emission.
Sourcepub fn record_emission(&mut self, now_ms: i64, bytes_done: u64)
pub fn record_emission(&mut self, now_ms: i64, bytes_done: u64)
Record that an event was just emitted.
Trait Implementations§
Source§impl Debug for ProgressThrottle
impl Debug for ProgressThrottle
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.