Skip to main content

affinidi_messaging_mediator_config/
lib.rs

1//! Raw TOML configuration schema for the Affinidi Messaging Mediator.
2//!
3//! This crate holds **only the serde deserialization types** that mirror the
4//! mediator's `mediator.toml` — the `*ConfigRaw` structs and their plain-serde
5//! sub-structs. Every field is the on-disk shape (mostly `String`, parsed into
6//! typed/runtime values later).
7//!
8//! It is intentionally dependency-light (serde + the lean tier of
9//! `affinidi-messaging-mediator-common`, for `DatabaseConfigRaw`). The
10//! **resolved** runtime `Config` — opened secret backends, JWT keys, the
11//! DID-resolver client, the VTA refresher — and all `ConfigRaw → Config`
12//! conversions stay in the mediator binary, which re-exports these types so
13//! existing `crate::common::config::*` paths keep resolving.
14//!
15//! The goal (mediator simplification T18) is one schema, two consumers: the
16//! mediator and (later) the `mediator-setup` wizard, which today renders this
17//! TOML by hand with no shared types. Env-var override logic and boot-time
18//! validation move here in a follow-up (T18b), once they carry a crate-local
19//! error type instead of the mediator's server-tier `MediatorError`.
20
21pub mod env;
22pub mod error;
23mod limits;
24mod processors;
25mod schema;
26mod security;
27pub mod validate;
28
29pub use error::ConfigError;
30pub use limits::*;
31pub use processors::*;
32pub use schema::*;
33pub use security::*;
34
35#[cfg(test)]
36mod golden {
37    use super::ConfigRaw;
38
39    /// The shipped `mediator.toml` must still deserialize into `ConfigRaw`
40    /// after the schema relocation — a structural guard that the moved types
41    /// stay byte-compatible with the real config the mediator parses.
42    #[test]
43    fn shipped_mediator_toml_parses() {
44        let toml = include_str!("../../conf/mediator.toml");
45        let raw: ConfigRaw =
46            ::toml::from_str(toml).expect("conf/mediator.toml parses as ConfigRaw");
47
48        // Spot-check a field from a few different sections so an accidental
49        // rename or moved field is caught, not just "it deserialized".
50        assert!(raw.mediator_did.starts_with("did"));
51        assert!(!raw.server.listen_address.is_empty());
52        assert!(!raw.security.global_acl_default.is_empty());
53        assert!(!raw.limits.message_size.is_empty());
54        assert!(!raw.processors.forwarding.enabled.is_empty());
55        assert!(!raw.secrets.backend.is_empty());
56    }
57}