use super::state::ContinuationState;
impl ContinuationState {
#[must_use]
pub fn update_loop_detection_counters(self, current_fingerprint: String) -> Self {
if self.last_effect_kind.as_deref() == Some(¤t_fingerprint) {
Self {
consecutive_same_effect_count: self.consecutive_same_effect_count.saturating_add(1),
..self
}
} else {
Self {
last_effect_kind: Some(current_fingerprint),
consecutive_same_effect_count: 1,
..self
}
}
}
#[must_use]
pub const fn is_loop_detected(&self) -> bool {
self.consecutive_same_effect_count >= self.max_consecutive_same_effect
}
}