Resolve compound outcomes

This commit is contained in:
Félix Saparelli 2021-08-22 23:23:01 +12:00
parent 7a709b9b4d
commit d2d0bb7be2
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 12 additions and 0 deletions

View File

@ -121,6 +121,13 @@ impl Outcome {
Self::Both(Box::new(one), Box::new(two))
}
fn resolve(self, is_running: bool) -> Self {
match (is_running, self) {
(true, Self::IfRunning(then, _)) => then.resolve(true),
(false, Self::IfRunning(_, otherwise)) => otherwise.resolve(false),
(ir, Self::Both(one, two)) => Self::both(one.resolve(ir), two.resolve(ir)),
(_, other) => other,
}
}
}
@ -178,6 +185,11 @@ pub async fn worker(
let outcome = outcome.get().cloned().unwrap_or_default();
debug!(?outcome, "handler finished");
let is_running = todo!();
let outcome = outcome.resolve(is_running);
debug!(?outcome, "outcome resolved");
}
debug!("action worker finished");