1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Declarative merging primitives used by the derive macro.
//!
//! The traits defined here allow configuration structs to be merged from a
//! sequence of declarative layers without exposing Figment in the public API.
//! Layers are represented as serialised [`serde_json::Value`] blobs so tests
//! and behavioural fixtures can compose deterministic inputs without touching
//! the filesystem. See the
//! [declarative merging design](https://github.com/leynos/ortho-config/blob/main/docs/design.md#introduce-declarative-configuration-merging)
//! for the architectural context and trade-offs.
//!
//! # Example
//!
//! ```rust
//! use ortho_config::declarative::{MergeComposer, MergeLayer};
//! use ortho_config::{DeclarativeMerge, OrthoConfig};
//! use serde::{Deserialize, Serialize};
//! use serde_json::json;
//!
//! #[derive(Debug, Deserialize, Serialize, OrthoConfig)]
//! #[ortho_config(prefix = "APP")]
//! struct AppConfig {
//! #[ortho_config(default = 3000)]
//! port: u16,
//! }
//!
//! let mut composer = MergeComposer::new();
//! composer.push_defaults(json!({"port": 3000}));
//! composer.push_cli(json!({"port": 4000}));
//!
//! let config = AppConfig::merge_from_layers(composer.layers())
//! .expect("layers merge successfully");
//! assert_eq!(config.port, 4000);
//! ```
//!
//! The derive generates an internal state machine that implements
//! [`DeclarativeMerge`], so `merge_from_layers` can iterate through
//! [`MergeLayer`] values deterministically.
pub use ;
pub use ;
pub use ;
pub use ;