Skip to main content

InFlightLedger

Struct InFlightLedger 

Source
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>

Source

pub fn new() -> Self

Source

pub fn with_history_window(history_window: f32) -> Self

Source

pub fn arm(&mut self, item: C)

Arm a new in-flight item.

Source

pub fn clear(&mut self)

Discard every in-flight item without finalizing any (e.g. abandoning a candidate that never earned an event).

Source

pub fn in_flight(&self) -> &[C]

The items currently in flight.

Source

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.

Source

pub fn any_in_flight(&self) -> bool

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source§

impl<C: InFlightItem> InFlightLedger<C>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<C: Clone> Clone for InFlightLedger<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for InFlightLedger<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> Default for InFlightLedger<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C: PartialEq> PartialEq for InFlightLedger<C>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C: PartialEq> StructuralPartialEq for InFlightLedger<C>

Auto Trait Implementations§

§

impl<C> Freeze for InFlightLedger<C>
where Vec<C>: Freeze,

§

impl<C> RefUnwindSafe for InFlightLedger<C>
where Vec<C>: RefUnwindSafe,

§

impl<C> Send for InFlightLedger<C>
where Vec<C>: Send,

§

impl<C> Sync for InFlightLedger<C>
where Vec<C>: Sync,

§

impl<C> Unpin for InFlightLedger<C>
where Vec<C>: Unpin,

§

impl<C> UnsafeUnpin for InFlightLedger<C>
where Vec<C>: UnsafeUnpin,

§

impl<C> UnwindSafe for InFlightLedger<C>
where Vec<C>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.