use crate::prelude::*;
pub trait Coordinatelike<const MCL: usize, const MCC: usize, const MPL: usize, S>:
Keylike<MCL, MCC, MPL, S>
{
fn wdm_timestamp(&self) -> Timestamp;
}
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Keylike<MCL, MCC, MPL, S>
for (S, Path<MCL, MCC, MPL>, Timestamp)
{
fn wdm_subspace_id(&self) -> &S {
&self.0
}
fn wdm_path(&self) -> &Path<MCL, MCC, MPL> {
&self.1
}
}
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Coordinatelike<MCL, MCC, MPL, S>
for (S, Path<MCL, MCC, MPL>, Timestamp)
{
fn wdm_timestamp(&self) -> Timestamp {
self.2
}
}
pub trait CoordinatelikeExt<const MCL: usize, const MCC: usize, const MPL: usize, S>:
Coordinatelike<MCL, MCC, MPL, S> + KeylikeExt<MCL, MCC, MPL, S>
{
fn wdm_coordinate_eq<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
{
self.wdm_key_eq(other) && self.wdm_timestamp() == other.wdm_timestamp()
}
fn wdm_coordinate_ne<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
{
self.wdm_key_ne(other) || self.wdm_timestamp() != other.wdm_timestamp()
}
fn wdm_is_in<G>(&self, grouping: &G) -> bool
where
G: Grouping<MCL, MCC, MPL, S>,
{
grouping.wdm_includes(self)
}
fn wdm_is_in_intersection<G>(&self, grouping1: &G, grouping2: &G) -> bool
where
G: Grouping<MCL, MCC, MPL, S>,
{
grouping1.wdm_includes_in_intersection(grouping2, self)
}
}
impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> CoordinatelikeExt<MCL, MCC, MPL, S>
for T
where
T: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
{
}