Skip to main content

Progress

Struct Progress 

Source
pub struct Progress(/* private fields */);
Expand description

The one thing a handler is given to say what it is doing.

Cheap to clone and safe to hold: cloning it does not create a second stream, and a silent handle costs nothing to call.

use majordomus_cli::execution::Progress;
// what a handler outside an execution is given
let silent = Progress::silent();
silent.step("scan", "Scanning");
silent.progress(1, Some(2), "half way");
silent.step_done("scan", true, None);
assert!(!silent.cancelled(), "nothing can cancel a call that is not an execution");
assert!(!silent.is_reporting());

Implementations§

Source§

impl Progress

Source

pub fn silent() -> Self

A handle that reports nothing: what every call outside an execution is given.

Source

pub fn reporting( store: Arc<ExecutionStore>, id: ExecutionId, cancel: Arc<AtomicBool>, ) -> Self

A handle that publishes into a store, for one execution.

Source

pub fn is_reporting(&self) -> bool

Is anybody listening? A handler that would do real work to produce a report — count the files it is about to walk, say — asks first.

Source

pub fn execution_id(&self) -> Option<&ExecutionId>

The execution this reports into, when there is one.

Source

pub fn cancelled(&self) -> bool

Has this execution been asked to stop?

Cancellation is cooperative and this is the whole of it: a handler that never asks runs to completion, and the capability’s own policy is what tells a client whether asking will achieve anything.

Source

pub fn cancellation(&self) -> CapabilityError

The error a handler returns when it stops because it was asked to.

Source

pub fn step(&self, name: &str, title: &str)

Enter a named phase.

Source

pub fn step_done(&self, name: &str, ok: bool, detail: Option<String>)

Leave a named phase, saying whether what it was asked to do happened.

Source

pub fn progress( &self, current: u64, total: Option<u64>, message: impl AsRef<str>, )

How far along.

Source

pub fn log(&self, message: impl AsRef<str>)

A line of output, from the handler itself.

Source

pub fn stream(&self, stream: LogStream, message: impl AsRef<str>)

A line of output, from a named stream.

Source

pub fn diagnostic(&self, diagnostic: ExecutionDiagnostic)

A structured finding.

Trait Implementations§

Source§

impl Clone for Progress

Source§

fn clone(&self) -> Progress

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Progress

Source§

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

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

impl Default for Progress

Source§

fn default() -> Progress

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

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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