Skip to main content

Child

Struct Child 

Source
pub struct Child<'a> { /* private fields */ }
Expand description

A planned child phase, owned by the code that called Pulse::split.

A Child is a Pulse: pass &child wherever &dyn Pulse is expected, or call check, step and split on it directly. Finish it once, after its work has joined. A tracker records Outcome::Abandoned for a child that is dropped unfinished, including on unwinding. It is two words wide. Completion consumes the owner, so it cannot be repeated:

ⓘ
use how_far::{Child, Outcome};
let child = Child::inert();
child.finish(Outcome::Succeeded).unwrap();
child.finish(Outcome::Succeeded).unwrap();

Implementations§

Source§

impl Child<'_>

Source

pub fn paced(&self, every: u64) -> Paced<'_>

Checkpoints that reach this child’s pulse once every every units; see Paced.

Source§

impl<'a> Child<'a>

Source

pub fn complete_inferred(self, outcome: Outcome)

Resolve an unused phase from its enclosing result, retaining inference evidence.

Source

pub fn plan( &self, execution: Execution, parts: &[PhaseSpec<'_>], ) -> Vec<Child<'_>>

Plan nested observations without introducing a new work error.

Source

pub fn new(pulse: impl ChildPulse + 'a) -> Self

Wrap one child returned from a Pulse::split implementation.

Source

pub const fn inert() -> Self

A child like those NoPulse hands out: it never stops, discards reports, and finishing it does nothing. Its work cannot be stopped through it and nobody sees its progress, so return it from Pulse::split only for parts that nobody needs to observe or stop.

Source

pub fn finish(self, outcome: Outcome) -> Result<(), PlanError>

Publish this child’s outcome. Its parent can finish only after every child has finished.

Fails without recording outcome if the child’s own children are still running; the consumed child is then dropped, so a tracker records it as abandoned. Finished children’s outcomes need not match: a successful child may retain a failed attempt it recovered from.

Trait Implementations§

Source§

impl Complete for Child<'_>

Source§

fn complete_as(self, outcome: Outcome)

Record an explicitly chosen outcome, resolving unfinished observations. Join workers before calling this. Started but uncompleted children are abandoned; untouched children are skipped on success, not run on error.
Source§

fn complete<T, E>(self, result: Result<T, E>) -> Result<T, E>
where E: AsStopReason,

Classify the error with AsStopReason, record completion, and return the original result. Read more
Source§

fn complete_classified<T, E>( self, result: Result<T, E>, is_stop: impl FnOnce(&E) -> bool, ) -> Result<T, E>

Complete with an explicit classifier, for a foreign error type that Rust’s orphan rules keep from implementing AsStopReason.
Source§

fn complete_with<T, E>( self, body: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<T, E>
where E: AsStopReason,

Run a multi-step body with this owner, then complete the owner with the body’s result and return that result unchanged. Read more
Source§

fn complete_with_classified<T, E>( self, is_stop: impl FnOnce(&E) -> bool, body: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<T, E>

complete_with with an explicit classifier, for a foreign error type that cannot implement AsStopReason, such as an error wrapped with its source location.
Source§

impl Debug for Child<'_>

Source§

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

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

impl Pulse for Child<'_>

Source§

fn record_issue(&self, error: PlanError)

Record a reporting-protocol problem for optional diagnostics. This never changes cancellation or the operation’s return value. Ordinary sinks may ignore it; diagnostic wrappers retain bounded evidence.
Source§

fn split( &self, execution: Execution, parts: &[PhaseSpec<'_>], ) -> Result<Vec<Child<'_>>, PlanError>

Split this phase into weighted children, in declared order. Read more
Source§

fn start(&self) -> Result<(), PlanError>

Mark this phase running, without counting or ending planning. Implementations without lifecycle observations may ignore this.
Source§

fn set_total(&self, total: Total) -> Result<(), PlanError>

Revise a leaf’s denominator without changing completed units or weights. Unsupported implementations return an error instead of losing the update.
Source§

fn share(&self) -> Result<SharedPulse, PlanError>

Share all pulse capabilities with owned work, but never completion rights. Read more
Source§

impl Report for Child<'_>

Source§

fn advance(&self, completed: u64)

Add completed finished units.
Source§

fn may_report(&self) -> bool

Whether reports have any effect. Read more
Source§

impl Stop for Child<'_>

Source§

fn check(&self) -> Result<(), StopReason>

Check if the operation should stop. Read more
Source§

fn may_stop(&self) -> bool

Returns true if this stop can ever signal a stop. Read more
Source§

fn should_stop(&self) -> bool

Returns true if the operation should stop. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Child<'a>

§

impl<'a> !UnwindSafe for Child<'a>

§

impl<'a> Freeze for Child<'a>

§

impl<'a> Send for Child<'a>

§

impl<'a> Sync for Child<'a>

§

impl<'a> Unpin for Child<'a>

§

impl<'a> UnsafeUnpin for Child<'a>

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> ProgressExt for T
where T: Stop + Report + ?Sized,

Source§

fn step(&self, completed: u64) -> Result<(), StopReason>

Count completed finished units, then check for cancellation. Read more
Source§

fn live(&self) -> Option<&Self>

The live pulse: this value, or None when it can neither stop nor report. Read more
Source§

fn split_array<const N: usize>( &self, execution: Execution, parts: [PhaseSpec<'_>; N], ) -> Result<[Child<'_>; N], PlanError>
where Self: Pulse,

Pulse::split into exactly N children, returned as an array. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.