schema/lib.rs
1//! Load a `flusso` configuration into a validated model.
2//!
3//! This is the front door to the configuration layer. [`load`] takes the path
4//! to a `flusso.toml`, reads the source and sinks from it, resolves and parses
5//! every index schema the file references, and hands back a single [`Config`].
6//!
7//! The format-specific crates (`schema-config-toml`, `schema-index-yaml`) and
8//! the core model (`schema-core`) sit underneath. Downstream code depends only
9//! on this crate and reaches the core types through its re-exports.
10//!
11//! # Example
12//!
13//! ```no_run
14//! let config = schema::load("flusso.toml")?;
15//!
16//! for (name, index) in &config.indexes {
17//! println!("{name}: table {} ({} fields)", index.schema.table, index.schema.fields.len());
18//! }
19//! # Ok::<(), schema::LoadError>(())
20//! ```
21
22// `serde_json` / `serde_yaml` are dev-dependencies used only by the
23// `schema_drift` integration test; allow them to look unused in the lib's own
24// test build (see `tests/schema_drift.rs`).
25#![cfg_attr(test, allow(unused_crate_dependencies))]
26
27mod compiled;
28mod deployment;
29mod loader;
30
31pub use compiled::{
32 CompileError, Compiled, FORMAT_VERSION, compile, from_bytes, load_compiled, to_bytes, write,
33};
34pub use deployment::{Config, Index, ServerConfig, Sink, Source};
35pub use loader::{LoadError, load};
36
37// Re-export the canonical schema vocabulary so downstream crates depend only on
38// `schema` rather than reaching into the sub-crates directly. The assembled
39// `Config` family (above) lives in this crate; everything else — the
40// identifiers, `IndexSchema`, `IndexMapping`, `FailurePolicy`, the per-sink
41// configs — is the cross-cutting vocabulary from `schema-core`.
42pub use schema_core::*;
43
44pub use schema_config_toml::CONFIG_SCHEMA;
45pub use schema_index_yaml::INDEX_SCHEMA;