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
impl Progress
Sourcepub fn silent() -> Self
pub fn silent() -> Self
A handle that reports nothing: what every call outside an execution is given.
Sourcepub fn reporting(
store: Arc<ExecutionStore>,
id: ExecutionId,
cancel: Arc<AtomicBool>,
) -> Self
pub fn reporting( store: Arc<ExecutionStore>, id: ExecutionId, cancel: Arc<AtomicBool>, ) -> Self
A handle that publishes into a store, for one execution.
Sourcepub fn is_reporting(&self) -> bool
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.
Sourcepub fn execution_id(&self) -> Option<&ExecutionId>
pub fn execution_id(&self) -> Option<&ExecutionId>
The execution this reports into, when there is one.
Sourcepub fn cancelled(&self) -> bool
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.
Sourcepub fn cancellation(&self) -> CapabilityError
pub fn cancellation(&self) -> CapabilityError
The error a handler returns when it stops because it was asked to.
Sourcepub fn step_done(&self, name: &str, ok: bool, detail: Option<String>)
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.
Sourcepub fn progress(
&self,
current: u64,
total: Option<u64>,
message: impl AsRef<str>,
)
pub fn progress( &self, current: u64, total: Option<u64>, message: impl AsRef<str>, )
How far along.
Sourcepub fn stream(&self, stream: LogStream, message: impl AsRef<str>)
pub fn stream(&self, stream: LogStream, message: impl AsRef<str>)
A line of output, from a named stream.
Sourcepub fn diagnostic(&self, diagnostic: ExecutionDiagnostic)
pub fn diagnostic(&self, diagnostic: ExecutionDiagnostic)
A structured finding.