hydro_lang/
boundedness.rs

1use sealed::sealed;
2
3use crate::keyed_singleton::{BoundedValue, KeyedSingletonBound};
4
5/// A marker trait indicating whether a stream’s length is bounded (finite) or unbounded (potentially infinite).
6///
7/// Implementors of this trait use it to signal the boundedness property of a stream.
8#[sealed]
9pub trait Boundedness: KeyedBoundFoldLike {}
10
11/// Marks the stream as being unbounded, which means that it is not
12/// guaranteed to be complete in finite time.
13pub enum Unbounded {}
14
15#[sealed]
16impl Boundedness for Unbounded {}
17
18/// Marks the stream as being bounded, which means that it is guaranteed
19/// to be complete in finite time.
20pub enum Bounded {}
21
22#[sealed]
23impl Boundedness for Bounded {}
24
25/// Helper trait that determines the boundedness for the result of keyed aggregations.
26#[sealed::sealed]
27pub trait KeyedBoundFoldLike {
28    /// The boundedness of the keyed singleton if the values for each key will asynchronously change.
29    type WhenValueUnbounded: KeyedSingletonBound<UnderlyingBound = Self>;
30    /// The boundedness of the keyed singleton if the value for each key is immutable.
31    type WhenValueBounded: KeyedSingletonBound<UnderlyingBound = Self>;
32}
33
34#[sealed::sealed]
35impl KeyedBoundFoldLike for Unbounded {
36    type WhenValueUnbounded = Unbounded;
37    type WhenValueBounded = BoundedValue;
38}
39
40#[sealed::sealed]
41impl KeyedBoundFoldLike for Bounded {
42    type WhenValueUnbounded = Bounded;
43    type WhenValueBounded = Bounded;
44}