#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub enum RangeRel {
Undefined,
Equal,
Before(bool),
Meets(bool),
Starts(bool),
Finishes(bool),
Overlaps(bool),
During(bool),
}
impl RangeRel {
pub fn is_undefined(&self) -> bool {
*self == Self::Undefined
}
pub fn is_equal(&self) -> bool {
*self == Self::Equal
}
pub fn is_bef_xxx(&self) -> bool {
matches!(*self, Self::Before(_))
}
pub fn is_bef_reg(&self) -> bool {
*self == Self::Before(true)
}
pub fn is_bef_inv(&self) -> bool {
*self == Self::Before(false)
}
pub fn is_met_xxx(&self) -> bool {
matches!(*self, Self::Meets(_))
}
pub fn is_met_reg(&self) -> bool {
*self == Self::Meets(true)
}
pub fn is_met_inv(&self) -> bool {
*self == Self::Meets(false)
}
pub fn is_stt_xxx(&self) -> bool {
matches!(*self, Self::Starts(_))
}
pub fn is_stt_reg(&self) -> bool {
*self == Self::Starts(true)
}
pub fn is_stt_inv(&self) -> bool {
*self == Self::Starts(false)
}
pub fn is_fin_xxx(&self) -> bool {
matches!(*self, Self::Finishes(_))
}
pub fn is_fin_reg(&self) -> bool {
*self == Self::Finishes(true)
}
pub fn is_fin_inv(&self) -> bool {
*self == Self::Finishes(false)
}
pub fn is_ovl_xxx(&self) -> bool {
matches!(*self, Self::Overlaps(_))
}
pub fn is_ovl_reg(&self) -> bool {
*self == Self::Overlaps(true)
}
pub fn is_ovl_inv(&self) -> bool {
*self == Self::Overlaps(false)
}
pub fn is_dur_xxx(&self) -> bool {
matches!(*self, Self::During(_))
}
pub fn is_dur_reg(&self) -> bool {
*self == Self::During(true)
}
pub fn is_dur_inv(&self) -> bool {
*self == Self::During(false)
}
pub fn is_intersects(&self) -> bool {
!matches!(*self, Self::Undefined | Self::Before(_) | Self::Meets(_))
}
pub fn is_includes(&self) -> bool {
matches!(
*self,
Self::Equal | Self::During(false) | Self::Starts(false) | Self::Finishes(false)
)
}
pub fn is_included(&self) -> bool {
matches!(
*self,
Self::Equal | Self::During(true) | Self::Starts(true) | Self::Finishes(true)
)
}
pub fn inverse(&self) -> Self {
match *self {
Self::Undefined => Self::Undefined,
Self::Equal => Self::Equal,
Self::Before(x) => Self::Before(!x),
Self::Meets(x) => Self::Meets(!x),
Self::Starts(x) => Self::Starts(!x),
Self::Finishes(x) => Self::Finishes(!x),
Self::Overlaps(x) => Self::Overlaps(!x),
Self::During(x) => Self::During(!x),
}
}
}