pub struct EventCompactor { /* private fields */ }Expand description
Incremental compactor that tracks realtime bar lifecycle.
Feed events via push and call finish when
the stream ends. The compactor:
- Forwards history events unchanged.
- Counts events per realtime bar and notifies
EventCompactionSink::on_realtime_confirmedon rollover or stream end. - Optionally drops
Event::Logand/orEvent::Alertevents.
Implementations§
Source§impl EventCompactor
impl EventCompactor
Sourcepub fn new(rules: EventCompactionRules) -> Self
pub fn new(rules: EventCompactionRules) -> Self
Create a new compactor with the given rules.
Sourcepub fn push<S>(&mut self, event: Event, sink: &mut S)where
S: EventCompactionSink,
pub fn push<S>(&mut self, event: Event, sink: &mut S)where
S: EventCompactionSink,
Push one event through the compactor.
The event is forwarded to sink.on_event (unless filtered) and the
realtime bar state is updated accordingly. When a new realtime bar
rolls over the previous one, sink.on_realtime_confirmed is called
before forwarding the new BarStart.
Sourcepub fn finish<S>(&mut self, sink: &mut S)where
S: EventCompactionSink,
pub fn finish<S>(&mut self, sink: &mut S)where
S: EventCompactionSink,
Signal stream completion.
If a realtime bar is still open, it is confirmed with
RealtimeConfirmReason::StreamEnd.
Auto Trait Implementations§
impl Freeze for EventCompactor
impl RefUnwindSafe for EventCompactor
impl Send for EventCompactor
impl Sync for EventCompactor
impl Unpin for EventCompactor
impl UnsafeUnpin for EventCompactor
impl UnwindSafe for EventCompactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.