pub struct InFlightLedger<C> { /* private fields */ }Expand description
Holds an unordered set of in-flight items, drives their lifecycle uniformly, and records recognitions so finalized and in-flight events alike can be queried latently.
Implementations§
Source§impl<C> InFlightLedger<C>
impl<C> InFlightLedger<C>
pub fn new() -> Self
pub fn with_history_window(history_window: f32) -> Self
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Discard every in-flight item without finalizing any (e.g. abandoning a candidate that never earned an event).
Sourcepub fn in_flight_mut(&mut self) -> &mut [C]
pub fn in_flight_mut(&mut self) -> &mut [C]
Mutable access to the items currently in flight, for per-frame accumulation that does not change the in-flight set.
pub fn any_in_flight(&self) -> bool
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Source§impl<C: InFlightItem> InFlightLedger<C>
impl<C: InFlightItem> InFlightLedger<C>
Sourcepub fn advance(
&mut self,
now: f32,
step: impl FnMut(&mut C) -> Disposition,
) -> Vec<(C, FinalizeReason)>
pub fn advance( &mut self, now: f32, step: impl FnMut(&mut C) -> Disposition, ) -> Vec<(C, FinalizeReason)>
Advance every in-flight item with step, which folds in this frame’s
data and returns a Disposition. Finalized and discarded items are
removed; finalized items are logged for latent queries and returned with
their reason for the caller to turn into events. now is the current
frame time, used to bound the latent-query history.
Sourcepub fn apply_boundary(&mut self, boundary: Boundary) -> Vec<(C, FinalizeReason)>
pub fn apply_boundary(&mut self, boundary: Boundary) -> Vec<(C, FinalizeReason)>
Apply boundary to every in-flight item via InFlightItem::on_boundary.
This is the uniform replacement for hand-placed flush calls: a single
call resolves every pending item against the boundary, so none can be
forgotten.
Sourcepub fn finish(&mut self) -> Vec<(C, FinalizeReason)>
pub fn finish(&mut self) -> Vec<(C, FinalizeReason)>
Finalize everything still in flight at end of stream. Calling this from a
node’s finish guarantees no in-flight item is ever silently dropped.
Sourcepub fn finalize_all(
&mut self,
reason: FinalizeReason,
) -> Vec<(C, FinalizeReason)>
pub fn finalize_all( &mut self, reason: FinalizeReason, ) -> Vec<(C, FinalizeReason)>
Imperatively finalize every in-flight item with reason, returning them
for the caller to convert into events. For calculators that drive
finalization from specific code paths (e.g. emit-early, patch-in-place)
rather than a per-frame step or a Boundary.
Sourcepub fn happened_within(
&self,
now: f32,
window: f32,
committed_only: bool,
) -> bool
pub fn happened_within( &self, now: f32, window: f32, committed_only: bool, ) -> bool
Whether an event was recognized within window seconds before now,
counting both finalized events and items still in flight.
With committed_only, speculative (not-yet-committed) in-flight items
are ignored — use it for “did X happen?” questions that must not be
fooled by a candidate that may still be discarded. Without it, the query
is fully latent: a just-recognized, not-yet-finalized candidate counts.
Sourcepub fn recognitions_within(
&self,
now: f32,
window: f32,
committed_only: bool,
) -> impl Iterator<Item = Recognition> + '_
pub fn recognitions_within( &self, now: f32, window: f32, committed_only: bool, ) -> impl Iterator<Item = Recognition> + '_
All recognitions within window seconds before now, across in-flight
and finalized items. See happened_within for
the meaning of committed_only.