use core::ops::RangeBounds;
use willow_data_model as wdm;
use crate::prelude::*;
pub use wdm::groupings::WillowRange;
mod keylike;
pub use keylike::*;
mod coordinatelike;
pub use coordinatelike::*;
mod namespaced;
pub use namespaced::*;
mod range_3d;
pub use range_3d::*;
mod area;
pub use area::*;
mod area_of_interest;
pub use area_of_interest::*;
pub mod private_context;
pub type SubspaceRange = WillowRange<SubspaceId>;
pub type PathRange = WillowRange<Path>;
pub type TimeRange = wdm::groupings::TimeRange;
pub trait Grouping: PartialOrd + Sized {
fn includes<Coord>(&self, coord: &Coord) -> bool
where
Coord: Coordinatelike + ?Sized;
fn includes_grouping(&self, other: &Self) -> bool {
self >= other
}
fn strictly_includes_grouping(&self, other: &Self) -> bool {
self > other
}
fn intersection(&self, other: &Self) -> Result<Self, wdm::prelude::EmptyGrouping>;
fn includes_in_intersection<Coord>(&self, other: &Self, coord: &Coord) -> bool
where
Coord: Coordinatelike + ?Sized,
{
self.includes(coord) && other.includes(coord)
}
}
impl Grouping for WillowRange<SubspaceId> {
fn includes<Coord>(&self, coord: &Coord) -> bool
where
Coord: Coordinatelike + ?Sized,
{
self.contains(coord.subspace_id())
}
fn intersection(&self, other: &Self) -> Result<Self, wdm::prelude::EmptyGrouping> {
self.intersection_willow_range(other)
}
}
impl Grouping for WillowRange<Path> {
fn includes<Coord>(&self, coord: &Coord) -> bool
where
Coord: Coordinatelike + ?Sized,
{
self.contains(coord.path())
}
fn intersection(&self, other: &Self) -> Result<Self, wdm::prelude::EmptyGrouping> {
self.intersection_willow_range(other)
}
}
impl Grouping for WillowRange<Timestamp> {
fn includes<Coord>(&self, coord: &Coord) -> bool
where
Coord: Coordinatelike + ?Sized,
{
self.contains(&coord.timestamp())
}
fn intersection(&self, other: &Self) -> Result<Self, wdm::prelude::EmptyGrouping> {
self.intersection_willow_range(other)
}
}