pub struct TimeWindow {
pub window_type: WindowType,
pub duration: Duration,
pub start_time: u64,
pub end_time: u64,
/* private fields */
}Expand description
Time-based window for event processing
Fields§
§window_type: WindowTypeWindow type
duration: DurationWindow duration
start_time: u64Window start time (milliseconds since epoch)
end_time: u64Window end time (milliseconds since epoch)
Implementations§
Source§impl TimeWindow
impl TimeWindow
Sourcepub fn new(
window_type: WindowType,
duration: Duration,
start_time: u64,
max_events: usize,
) -> Self
pub fn new( window_type: WindowType, duration: Duration, start_time: u64, max_events: usize, ) -> Self
Create a new time window
Sourcepub fn add_event(&mut self, event: StreamEvent) -> bool
pub fn add_event(&mut self, event: StreamEvent) -> bool
Add event to window if it fits
Sourcepub fn contains_timestamp(&self, timestamp: u64) -> bool
pub fn contains_timestamp(&self, timestamp: u64) -> bool
Check if timestamp falls within this window
Sourcepub fn events(&self) -> &VecDeque<StreamEvent>
pub fn events(&self) -> &VecDeque<StreamEvent>
Get all events in window
Sourcepub fn is_expired(&self, current_time: u64) -> bool
pub fn is_expired(&self, current_time: u64) -> bool
Check if window is expired
Sourcepub fn duration_ms(&self) -> u64
pub fn duration_ms(&self) -> u64
Get window duration in milliseconds
Sourcepub fn events_by_type(&self, event_type: &str) -> Vec<&StreamEvent>
pub fn events_by_type(&self, event_type: &str) -> Vec<&StreamEvent>
Get events filtered by type
Sourcepub fn average(&self, field: &str) -> Option<f64>
pub fn average(&self, field: &str) -> Option<f64>
Calculate average of numeric field across events
Sourcepub fn latest_timestamp(&self) -> Option<u64>
pub fn latest_timestamp(&self) -> Option<u64>
Get the latest event timestamp
Sourcepub fn events_in_range(&self, start: u64, end: u64) -> Vec<&StreamEvent>
pub fn events_in_range(&self, start: u64, end: u64) -> Vec<&StreamEvent>
Get events within a sub-window
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TimeWindow
impl RefUnwindSafe for TimeWindow
impl Send for TimeWindow
impl Sync for TimeWindow
impl Unpin for TimeWindow
impl UnwindSafe for TimeWindow
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