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 identity (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::EntityFieldModel, 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
30pub struct EntityModel {
31    /// Fully-qualified Rust type path (for diagnostics).
32    pub path: &'static str,
33
34    /// Stable external name used in keys and routing.
35    pub entity_name: &'static str,
36
37    /// Primary key field (points at an entry in `fields`).
38    pub primary_key: &'static EntityFieldModel,
39
40    /// Ordered field list (authoritative for runtime planning).
41    pub fields: &'static [EntityFieldModel],
42
43    /// Index definitions (field order is significant).
44    pub indexes: &'static [&'static IndexModel],
45}