Skip to main content

Meter

Struct Meter 

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

A lock-free progress meter shared across threads behind an Arc.

Every method takes &self and uses Ordering::Relaxed — the counters are advisory progress, never a synchronization primitive, so relaxed ordering is both correct and cheap (a couple of atomic ops per file). Meter is Send + Sync because all of its fields are atomics.

Implementations§

Source§

impl Meter

Source

pub fn new() -> Self

Creates a fresh meter with all counters at zero and Phase::Idle.

Source

pub fn add_in(&self, n: u64)

Adds n to the bytes-in counter (content read/hashed).

Source

pub fn add_out(&self, n: u64)

Adds n to the bytes-out counter (content written/sent).

Source

pub fn object_started(&self)

Records that an object started: bumps the in-flight gauge by one.

Source

pub fn object_finished(&self)

Records that an object finished: drops the in-flight gauge by one and bumps the done counter by one. Saturates the gauge at zero so a stray finish never underflows.

Source

pub fn set_total(&self, n: u64)

Sets the expected total object count.

Source

pub fn add_skipped(&self, n: u64)

Adds n to the skipped-objects counter.

Source

pub fn set_current_limit(&self, n: u64)

Sets the advisory adaptive throughput limit (bytes/sec; 0 = unset).

Display-only: the renderer reads this to show the live adaptive value. It does not throttle or otherwise change the walk’s behavior or output.

Source

pub fn set_target_rate(&self, n: u64)

Sets the advisory adaptive target throughput (bytes/sec; 0 = unset).

Display-only, with the same advisory semantics as set_current_limit.

Source

pub fn set_phase(&self, p: Phase)

Sets the current coarse Phase.

Source

pub fn phase(&self) -> Phase

Reads the current coarse Phase.

Source

pub fn snapshot(&self) -> MeterSnapshot

Takes a point-in-time MeterSnapshot of every counter.

The loads are independently relaxed, so the snapshot is eventually consistent rather than a single atomic view — that is fine for an advisory progress display.

Trait Implementations§

Source§

impl Debug for Meter

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Meter

Source§

fn default() -> Meter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Meter

§

impl RefUnwindSafe for Meter

§

impl Send for Meter

§

impl Sync for Meter

§

impl Unpin for Meter

§

impl UnsafeUnpin for Meter

§

impl UnwindSafe for Meter

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> 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 = 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.