use crate::prelude::*;
pub trait Coordinatelike: Keylike {
fn timestamp(&self) -> Timestamp;
}
impl Keylike for (SubspaceId, Path, Timestamp) {
fn subspace_id(&self) -> &SubspaceId {
&self.0
}
fn path(&self) -> &Path {
&self.1
}
}
impl Coordinatelike for (SubspaceId, Path, Timestamp) {
fn timestamp(&self) -> Timestamp {
self.2
}
}
impl Keylike for (SubspaceId, Timestamp, Path) {
fn subspace_id(&self) -> &SubspaceId {
&self.0
}
fn path(&self) -> &Path {
&self.2
}
}
impl Coordinatelike for (SubspaceId, Timestamp, Path) {
fn timestamp(&self) -> Timestamp {
self.1
}
}
impl Keylike for (Path, SubspaceId, Timestamp) {
fn subspace_id(&self) -> &SubspaceId {
&self.1
}
fn path(&self) -> &Path {
&self.0
}
}
impl Coordinatelike for (Path, SubspaceId, Timestamp) {
fn timestamp(&self) -> Timestamp {
self.2
}
}
impl Keylike for (Path, Timestamp, SubspaceId) {
fn subspace_id(&self) -> &SubspaceId {
&self.2
}
fn path(&self) -> &Path {
&self.0
}
}
impl Coordinatelike for (Path, Timestamp, SubspaceId) {
fn timestamp(&self) -> Timestamp {
self.1
}
}
impl Keylike for (Timestamp, SubspaceId, Path) {
fn subspace_id(&self) -> &SubspaceId {
&self.1
}
fn path(&self) -> &Path {
&self.2
}
}
impl Coordinatelike for (Timestamp, SubspaceId, Path) {
fn timestamp(&self) -> Timestamp {
self.0
}
}
impl Keylike for (Timestamp, Path, SubspaceId) {
fn subspace_id(&self) -> &SubspaceId {
&self.2
}
fn path(&self) -> &Path {
&self.1
}
}
impl Coordinatelike for (Timestamp, Path, SubspaceId) {
fn timestamp(&self) -> Timestamp {
self.0
}
}
pub trait CoordinatelikeExt: Coordinatelike + KeylikeExt {
fn coordinate_eq<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where
OtherCoordinate: Coordinatelike,
{
self.key_eq(other) && self.timestamp() == other.timestamp()
}
fn coordinate_ne<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where
OtherCoordinate: Coordinatelike,
{
self.key_ne(other) || self.timestamp() != other.timestamp()
}
fn is_in<G>(&self, grouping: &G) -> bool
where
G: Grouping,
{
grouping.includes(self)
}
fn is_in_intersection<G>(&self, grouping1: &G, grouping2: &G) -> bool
where
G: Grouping,
{
grouping1.includes_in_intersection(grouping2, self)
}
}
impl<T> CoordinatelikeExt for T where T: Coordinatelike + ?Sized {}