Skip to main content

schema/deployment/
projection.rs

1//! Projecting the enabled indexes of a [`Config`] into fully-typed mappings.
2//!
3//! The per-index projection (schema → mapping) is database-free and lives in
4//! `schema-core` as [`IndexSchema::resolve`](schema_core::IndexSchema::resolve);
5//! this is just the composition layer that walks the config's enabled indexes.
6
7use schema_core::IndexMapping;
8
9use super::Config;
10
11impl Config {
12    /// Project every **enabled** index into a fully-typed [`IndexMapping`],
13    /// using only the declared schema. The engine runs it up front so each index
14    /// is created from a complete description without touching the database.
15    pub fn resolve_mappings(&self) -> Vec<IndexMapping> {
16        self.indexes
17            .iter()
18            .filter(|(_, index)| index.enabled)
19            .map(|(name, index)| index.schema.resolve(name.clone()))
20            .collect()
21    }
22}