mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-29 05:11:19 -08:00
28 lines
1.0 KiB
Rust
28 lines
1.0 KiB
Rust
//! The retry rule and the strength step-up, called by both the Implementation
|
|||
|
|
//! Loop and the Review Loop.
|
||
|
|
|
||
|
|
use std::collections::BTreeMap;
|
||
|
|
|
||
|
|
use crate::loop_driver::{LoopSetup, StopCause};
|
||
|
|
use crate::models::{self, StrengthRow};
|
||
|
|
|
||
|
|
/// One fresh retry for a crash, silence or an announce notice that never came
|
||
|
|
/// (a crash), when the setup allows it and the phase has not used it yet. A
|
||
|
|
/// failed watcher is never retried.
|
||
|
|
pub fn should_retry(cause: &StopCause, setup: &LoopSetup, retries_used_this_phase: u32) -> bool {
|
||
|
|
matches!(
|
||
|
|
cause,
|
||
|
|
StopCause::Crash | StopCause::Silence | StopCause::NoSession
|
||
|
|
) && setup.retry_once
|
||
|
|
&& retries_used_this_phase == 0
|
||
|
|
}
|
||
|
|
|
||
|
|
/// The strength word one step above `current`, or `None` when there is none
|
||
|
|
/// (Best stays, an unmapped word stays). A thin wrapper over
|
||
|
|
/// `models::next_strength`, so a caller without a `RunningRecord` can step up.
|
||
|
|
pub fn next_strength_word(
|
||
|
|
resolved: &BTreeMap<String, StrengthRow>,
|
||
|
|
current: &str,
|
||
|
|
) -> Option<String> {
|
||
|
|
models::next_strength(resolved, current)
|
||
|
|
}
|