icydb-core 0.145.2

IcyDB — A schema-first typed query engine and persistence runtime for Internet Computer canisters
Documentation
use crate::db::query::plan::AggregateKind;

///
/// AggregateExplain
///
/// AggregateExplain is the shared explain-only projection
/// contract for fluent aggregate domains that can render one `AggregateExpr`.
/// It keeps session/query explain projection generic without collapsing the
/// execution domain boundaries that still stay family-specific.
///

pub(in crate::db) trait AggregateExplain {
    /// Return the explain-visible aggregate kind when this strategy family can
    /// project one aggregate terminal plan shape.
    fn explain_aggregate_kind(&self) -> Option<AggregateKind>;

    /// Return the explain-visible projected field label, if any.
    fn explain_projected_field(&self) -> Option<&str> {
        None
    }
}

///
/// ProjectionExplain
///
/// ProjectionExplain is the shared explain-only projection contract for
/// fluent projection terminal descriptors.
/// It lets session explain stay generic over concrete descriptor types without
/// reintroducing a projection strategy enum.
///

pub(in crate::db) trait ProjectionExplain {
    /// Return the stable projection explain descriptor for this terminal.
    fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_>;
}

///
/// ProjectionExplainDescriptor
///
/// ProjectionExplainDescriptor is the stable explain projection
/// surface for fluent projection/distinct terminals.
/// It carries the already-decided descriptor labels explain needs so query
/// intent does not rebuild projection terminal shape from executor requests.
///

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(in crate::db) struct ProjectionExplainDescriptor<'a> {
    pub(in crate::db::query::builder::aggregate) terminal: &'static str,
    pub(in crate::db::query::builder::aggregate) field: &'a str,
    pub(in crate::db::query::builder::aggregate) output: &'static str,
}

impl<'a> ProjectionExplainDescriptor<'a> {
    /// Return the stable explain terminal label.
    #[must_use]
    pub(in crate::db) const fn terminal_label(self) -> &'static str {
        self.terminal
    }

    /// Return the stable explain field label.
    #[must_use]
    pub(in crate::db) const fn field_label(self) -> &'a str {
        self.field
    }

    /// Return the stable explain output-shape label.
    #[must_use]
    pub(in crate::db) const fn output_label(self) -> &'static str {
        self.output
    }
}