pub struct LifecycleRunner<I: Indicator + Clone> { /* private fields */ }Expand description
Wraps an Indicator + Clone so BarLifecycle::Open/BarLifecycle::Update events can be
replayed any number of times without permanently mutating state, and only
BarLifecycle::Confirmed/BarLifecycle::Correction commit a new checkpoint.
Implementations§
Source§impl<I: Indicator + Clone> LifecycleRunner<I>
impl<I: Indicator + Clone> LifecycleRunner<I>
pub fn new(indicator: I) -> Self
Sourcepub fn confirmed_indicator(&self) -> Option<&I>
pub fn confirmed_indicator(&self) -> Option<&I>
The indicator state as of the last confirmed/corrected bar (never a tentative
open/update). None before the first confirmation.
Sourcepub fn on_event(&mut self, event: BarLifecycle) -> Option<IndicatorOutput>
pub fn on_event(&mut self, event: BarLifecycle) -> Option<IndicatorOutput>
Processes one lifecycle event and returns the resulting output.
Open/Update always start from the last confirmed checkpoint (or a freshly reset
indicator if none exists yet) before applying bar, so repeated calls for the same
still-forming timestamp are idempotent and never stack on top of a prior tentative
application. Confirmed/Correction do the same, then persist the resulting state as the
new checkpoint.