use sealed::sealed;
use super::keyed_singleton::KeyedSingletonBound;
use crate::compile::ir::BoundKind;
use crate::live_collections::singleton::SingletonBound;
#[sealed]
pub trait Boundedness:
SingletonBound<UnderlyingBound = Self> + KeyedSingletonBound<UnderlyingBound = Self>
{
const BOUNDED: bool;
const BOUND_KIND: BoundKind = if Self::BOUNDED {
BoundKind::Bounded
} else {
BoundKind::Unbounded
};
type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering>: crate::live_collections::stream::Ordering;
}
pub enum Unbounded {}
#[sealed]
impl Boundedness for Unbounded {
const BOUNDED: bool = false;
type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering> =
crate::live_collections::stream::NoOrder;
}
pub enum Bounded {}
#[sealed]
impl Boundedness for Bounded {
const BOUNDED: bool = true;
type PreserveOrderIfBounded<InO: crate::live_collections::stream::Ordering> = InO;
}
#[sealed]
#[diagnostic::on_unimplemented(
message = "The input collection must be bounded (`Bounded`), but has bound `{Self}`. Strengthen the boundedness upstream or consider a different API.",
label = "required here",
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."
)]
pub trait IsBounded: Boundedness {}
#[sealed]
#[diagnostic::do_not_recommend]
impl IsBounded for Bounded {}