hydro_lang/live_collections/
boundedness.rs1use sealed::sealed;
5
6use super::keyed_singleton::KeyedSingletonBound;
7use crate::compile::ir::BoundKind;
8use crate::live_collections::singleton::SingletonBound;
9
10#[sealed]
14pub trait Boundedness:
15 SingletonBound<UnderlyingBound = Self> + KeyedSingletonBound<UnderlyingBound = Self>
16{
17 const BOUNDED: bool;
19
20 const BOUND_KIND: BoundKind = if Self::BOUNDED {
22 BoundKind::Bounded
23 } else {
24 BoundKind::Unbounded
25 };
26
27 type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering>: crate::live_collections::stream::Ordering;
33}
34
35pub enum Unbounded {}
38
39#[sealed]
40impl Boundedness for Unbounded {
41 const BOUNDED: bool = false;
42 type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering> =
43 crate::live_collections::stream::NoOrder;
44}
45
46pub enum Bounded {}
49
50#[sealed]
51impl Boundedness for Bounded {
52 const BOUNDED: bool = true;
53 type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering> = InO;
54}
55
56#[sealed]
57#[diagnostic::on_unimplemented(
58 message = "The input collection must be bounded (`Bounded`), but has bound `{Self}`. Strengthen the boundedness upstream or consider a different API.",
59 label = "required here",
60 note = "To intentionally process a non-deterministic snapshot or batch, you may want to use a `sliced!` region. This introduces non-determinism so avoid unless necessary."
61)]
62pub trait IsBounded: Boundedness {}
64
65#[sealed]
66#[diagnostic::do_not_recommend]
67impl IsBounded for Bounded {}