deep_causality_context 0.2.0

Context hypergraph, context node types, and contextuable traits for DeepCausality.
Documentation
/*
 * SPDX-License-Identifier: MIT
 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
 */

use crate::{ContextoidType, Datable, SpaceTemporal, Spatial, Temporal};
use deep_causality_core::Identifiable;

pub mod coordinate;
pub mod datable;
pub mod datable_uncertain;
pub mod distance;
pub mod metric_signature;
pub mod metric_tensor;
pub mod space_temporal;
pub mod spatial;
pub mod temporal;

/// Represents any entity that participates in a causal context graph.
///
/// This trait defines the unified interface over any entity that may be:
/// - A data node
/// - A spatial or temporal marker
/// - A spacetime event
///
/// It is designed to **abstract over the underlying causal semantics**
/// while retaining compile-time type safety and minimal trait bounds.
///
/// # Type Parameters
/// - `D`: A [`Datable`] node (e.g., sensor reading, fact, entity)
/// - `S`: A [`Spatial`] node
/// - `T`: A [`Temporal`] node
/// - `ST`: A [`SpaceTemporal`] node (4D entity)
///
/// # Design Note
/// This trait is the dispatch point for `ContextoidType`, allowing static or
/// dynamic graph traversal based on node kind. It intentionally generalizes
/// over all possible causal node roles.
pub trait Contextuable<D, S, T, ST>: Identifiable
where
    D: Datable + Clone,
    S: Spatial + Clone,
    T: Temporal + Clone,
    ST: SpaceTemporal + Clone,
{
    /// Returns a reference to the type-erased node variant.
    ///
    /// Use this to determine the role of the current node (data, space, time, etc.)
    /// and then downcast or dispatch accordingly.
    fn vertex_type(&self) -> &ContextoidType<D, S, T, ST>;
}