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<'a> Child<'a>
impl<'a> Child<'a>
Sourcepub fn complete_inferred(self, outcome: Outcome)
pub fn complete_inferred(self, outcome: Outcome)
Resolve an unused phase from its enclosing result, retaining inference evidence.
Sourcepub fn plan(
&self,
execution: Execution,
parts: &[PhaseSpec<'_>],
) -> Vec<Child<'_>>
pub fn plan( &self, execution: Execution, parts: &[PhaseSpec<'_>], ) -> Vec<Child<'_>>
Plan nested observations without introducing a new work error.
Sourcepub fn new(pulse: impl ChildPulse + 'a) -> Self
pub fn new(pulse: impl ChildPulse + 'a) -> Self
Wrap one child returned from a Pulse::split implementation.
Sourcepub const fn inert() -> Self
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.
Sourcepub fn finish(self, outcome: Outcome) -> Result<(), PlanError>
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<'_>
impl Complete for Child<'_>
Source§fn complete_as(self, outcome: Outcome)
fn complete_as(self, outcome: Outcome)
Source§fn complete<T, E>(self, result: Result<T, E>) -> Result<T, E>where
E: AsStopReason,
fn complete<T, E>(self, result: Result<T, E>) -> Result<T, E>where
E: AsStopReason,
AsStopReason, record completion, and return the
original result. Read moreSource§fn complete_classified<T, E>(
self,
result: Result<T, E>,
is_stop: impl FnOnce(&E) -> bool,
) -> Result<T, E>
fn complete_classified<T, E>( self, result: Result<T, E>, is_stop: impl FnOnce(&E) -> bool, ) -> Result<T, E>
AsStopReason.Source§fn complete_with<T, E>(
self,
body: impl FnOnce(&mut Self) -> Result<T, E>,
) -> Result<T, E>where
E: AsStopReason,
fn complete_with<T, E>(
self,
body: impl FnOnce(&mut Self) -> Result<T, E>,
) -> Result<T, E>where
E: AsStopReason,
body with this owner, then complete the owner with
the body’s result and return that result unchanged. Read moreSource§fn complete_with_classified<T, E>(
self,
is_stop: impl FnOnce(&E) -> bool,
body: impl FnOnce(&mut Self) -> Result<T, E>,
) -> Result<T, E>
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.