use core::fmt;
#[cfg(feature = "dev")]
use arbitrary::Arbitrary;
use crate::prelude::*;
mod willow_range;
pub use willow_range::*;
mod range_3d;
pub use range_3d::*;
mod area;
pub use area::*;
mod area_of_interest;
pub use area_of_interest::*;
mod keylike;
pub use keylike::*;
mod coordinatelike;
pub use coordinatelike::*;
mod namespaced;
pub use namespaced::*;
pub mod private_interest;
pub type SubspaceRange<S> = WillowRange<S>;
pub type PathRange<const MCL: usize, const MCC: usize, const MPL: usize> =
WillowRange<Path<MCL, MCC, MPL>>;
pub type TimeRange = WillowRange<Timestamp>;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "dev", derive(Arbitrary))]
pub struct EmptyGrouping;
impl fmt::Display for EmptyGrouping {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"An operation would have resulted in an empty grouping of Willow entries."
)
}
}
impl core::error::Error for EmptyGrouping {}
pub trait Grouping<const MCL: usize, const MCC: usize, const MPL: usize, S>:
PartialOrd + Sized
{
fn wdm_includes<Coord>(&self, coord: &Coord) -> bool
where
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized;
fn wdm_includes_grouping(&self, other: &Self) -> bool {
self >= other
}
fn wdm_strictly_includes_grouping(&self, other: &Self) -> bool {
self > other
}
fn wdm_intersection(&self, other: &Self) -> Result<Self, EmptyGrouping>
where
S: Clone;
fn wdm_includes_in_intersection<Coord>(&self, other: &Self, coord: &Coord) -> bool
where
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
{
self.wdm_includes(coord) && other.wdm_includes(coord)
}
}
pub fn subspace_includes_subspace<S: PartialEq>(outer: Option<&S>, inner: Option<&S>) -> bool {
match (outer, inner) {
(Some(s1), Some(s2)) => s1 == s2,
(Some(_), None) => false,
_ => true,
}
}