Skip to main content

icydb_core/model/
entity.rs

1//! Runtime-only entity schema surface generated by macros.
2//!
3//! This model intentionally includes only:
4//! - entity metadata (path + stable external name)
5//! - ordered fields
6//! - primary key field
7//! - index definitions
8//!
9//! It intentionally excludes:
10//! - validators/sanitizers/defaults
11//! - relations or full schema graphs
12//! - JSON schema ingestion or global registries
13//!
14//! Stability: this is the authoritative runtime contract for planning and
15//! execution. Additive changes are expected; breaking changes require a
16//! coordinated version bump across the engine.
17//!
18//! Field names are entity-scoped. Callers that combine entities must
19//! namespace by entity at the call site.
20
21use crate::model::{field::FieldModel, index::IndexModel};
22
23///
24/// EntityModel
25///
26/// Macro-generated runtime schema snapshot for a single entity.
27/// The planner and predicate validator consume this model directly.
28///
29
30#[derive(Debug)]
31pub struct EntityModel {
32    /// Fully-qualified Rust type path (for diagnostics).
33    pub path: &'static str,
34
35    /// Stable external name used in keys and routing.
36    pub entity_name: &'static str,
37
38    /// Primary key field (points at an entry in `fields`).
39    pub primary_key: &'static FieldModel,
40
41    /// Ordered field list (authoritative for runtime planning).
42    pub fields: &'static [FieldModel],
43
44    /// Index definitions (field order is significant).
45    pub indexes: &'static [&'static IndexModel],
46}