indexbus_platform_config/lib.rs
1//! Configuration conventions for IndexBus applications.
2//!
3//! `indexbus-platform-config` is a **platform layer** (std-first) intended to be used alongside
4//! `indexbus-kit`.
5//!
6//! **What this crate provides**
7//! - A small key/value loader for `KEY=VALUE` files and environment variables.
8//! - Explicit, documented precedence rules for layering sources.
9//! - Minimal error types intended for logging and user-facing diagnostics.
10//!
11//! **Feature requirements**
12//! - `std` (required): this crate currently depends on filesystem and environment access.
13//!
14//! **Contracts**
15//! - Layering is explicit and deterministic: later sources override earlier sources by key.
16//! - Environment variable keys are optionally normalized to support nested keys (see [`kv`]).
17//! - This crate intentionally does not implement a schema system; applications own their schema
18//! and validation.
19//!
20//! # Example
21//! ```no_run
22//! use indexbus_platform_config::config::ConfigStack;
23//! use indexbus_platform_config::kv::ConfigMap;
24//!
25//! let defaults: ConfigMap = [("http.port".to_string(), "8080".to_string())]
26//! .into_iter()
27//! .collect();
28//!
29//! let stack = ConfigStack::new()
30//! .with_defaults()
31//! .with_file_path("./app.env")
32//! .with_env_prefix("APP_");
33//!
34//! let merged = stack.load_kv_map(defaults)?;
35//! # Ok::<(), indexbus_platform_config::errors::Error>(())
36//! ```
37
38#![cfg_attr(not(feature = "std"), no_std)]
39#![deny(missing_docs)]
40
41#[cfg(all(not(feature = "std"), not(doc)))]
42compile_error!("indexbus-platform-config currently requires the `std` feature");
43
44#[cfg(feature = "std")]
45extern crate std;
46
47/// Error types and `Result` aliases.
48pub mod errors;
49/// Common re-exports for consumers of this crate.
50pub mod prelude;
51
52/// High-level configuration conventions and layering.
53pub mod config;
54/// Minimal `KEY=VALUE` configuration loader.
55pub mod kv;
56
57mod internal;