pub struct KeyedInFlightLedger<K, C> { /* private fields */ }Expand description
Holds at most one in-flight item per key, drives their lifecycle uniformly,
and records recognitions for latent queries. The keyed analogue of
InFlightLedger, for calculators that track a candidate per subject (e.g.
per player).
Implementations§
Source§impl<K, C> KeyedInFlightLedger<K, C>
impl<K, C> KeyedInFlightLedger<K, C>
Source§impl<K: Eq + Hash + Clone, C> KeyedInFlightLedger<K, C>
impl<K: Eq + Hash + Clone, C> KeyedInFlightLedger<K, C>
pub fn contains(&self, key: &K) -> bool
pub fn get(&self, key: &K) -> Option<&C>
pub fn get_mut(&mut self, key: &K) -> Option<&mut C>
Sourcepub fn entry_or_insert_with(
&mut self,
key: K,
default: impl FnOnce() -> C,
) -> &mut C
pub fn entry_or_insert_with( &mut self, key: K, default: impl FnOnce() -> C, ) -> &mut C
Access the in-flight item for key, inserting one produced by default
if absent. Mirrors HashMap::entry(..).or_insert_with(..).
pub fn keys(&self) -> impl Iterator<Item = &K> + '_
pub fn values(&self) -> impl Iterator<Item = &C> + '_
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut C> + '_
pub fn iter(&self) -> impl Iterator<Item = (&K, &C)> + '_
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut C)> + '_
Sourcepub fn retain(&mut self, keep: impl FnMut(&K, &C) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&K, &C) -> bool)
Keep only the items for which keep returns true, discarding the rest
without finalizing them (e.g. pruning stale candidates).
Source§impl<K: Eq + Hash + Clone, C: InFlightItem> KeyedInFlightLedger<K, C>
impl<K: Eq + Hash + Clone, C: InFlightItem> KeyedInFlightLedger<K, C>
Sourcepub fn finalize(&mut self, key: &K, _reason: FinalizeReason) -> Option<C>
pub fn finalize(&mut self, key: &K, _reason: FinalizeReason) -> Option<C>
Finalize the item for key, logging it for latent queries and returning
it for the caller to convert into an event.
Sourcepub fn advance(
&mut self,
now: f32,
step: impl FnMut(&K, &mut C) -> Disposition,
) -> Vec<(K, C, FinalizeReason)>
pub fn advance( &mut self, now: f32, step: impl FnMut(&K, &mut C) -> Disposition, ) -> Vec<(K, C, FinalizeReason)>
Advance every in-flight item with step, which receives the key and a
mutable item and returns a Disposition. now bounds the latent-query
history. Finalized items are returned with their key and reason.
Sourcepub fn apply_boundary(
&mut self,
boundary: Boundary,
) -> Vec<(K, C, FinalizeReason)>
pub fn apply_boundary( &mut self, boundary: Boundary, ) -> Vec<(K, C, FinalizeReason)>
Apply boundary to every in-flight item via InFlightItem::on_boundary.
Sourcepub fn finish(&mut self) -> Vec<(K, C, FinalizeReason)>
pub fn finish(&mut self) -> Vec<(K, C, FinalizeReason)>
Finalize everything still in flight at end of stream.
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.