WindowState

Struct WindowState 

Source
pub struct WindowState<W: Window, T> {
    pub window: W,
    pub elements: Vec<(DateTime<Utc>, T)>,
    pub count: usize,
    pub triggered: bool,
    pub last_watermark: Option<Watermark>,
}
Expand description

Tracks the state of a window including its watermark context.

Fields§

§window: W

The window this state belongs to.

§elements: Vec<(DateTime<Utc>, T)>

Elements currently in the window.

§count: usize

Count of elements.

§triggered: bool

Whether the window has been triggered.

§last_watermark: Option<Watermark>

Last watermark that affected this window.

Implementations§

Source§

impl<W: Window, T: Clone> WindowState<W, T>

Source

pub fn new(window: W) -> Self

Creates a new window state.

Source

pub fn add(&mut self, timestamp: DateTime<Utc>, element: T)

Adds an element to the window.

Source

pub fn update_watermark(&mut self, watermark: Watermark)

Updates the watermark for this window.

Source

pub fn can_be_gc( &self, current_watermark: &Watermark, allowed_lateness: ChronoDuration, ) -> bool

Returns true if the window should be garbage collected.

A window can be GC’d if it has been triggered and the watermark has passed the window’s end time plus allowed lateness.

Source

pub fn clear(&mut self)

Clears all elements from the window.

Source

pub fn mark_triggered(&mut self)

Marks the window as triggered.

Source

pub fn elements(&self) -> &[(DateTime<Utc>, T)]

Returns the elements as a slice.

Source

pub fn values(&self) -> Vec<T>

Extracts the element values without timestamps.

Trait Implementations§

Source§

impl<W: Window, T: Clone> Clone for WindowState<W, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<W: Debug + Window, T: Debug> Debug for WindowState<W, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W, T> Freeze for WindowState<W, T>
where W: Freeze,

§

impl<W, T> RefUnwindSafe for WindowState<W, T>

§

impl<W, T> Send for WindowState<W, T>
where T: Send,

§

impl<W, T> Sync for WindowState<W, T>
where T: Sync,

§

impl<W, T> Unpin for WindowState<W, T>
where W: Unpin, T: Unpin,

§

impl<W, T> UnwindSafe for WindowState<W, T>
where W: UnwindSafe, T: 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.