cfgmatic-schema
Schema and introspection types for cfgmatic v5.
cfgmatic-schema provides a stable manual schema model that can enrich merge reports with diagnostics.
Installation
[dependencies]
cfgmatic-schema = "5"
serde_json = "1"
Core types
SchemaNode
SchemaKind
EnvBinding
MergeHint
ValidationRule
ConfigSchema
Example
use cfgmatic_schema::{ConfigSchema, SchemaKind, SchemaNode};
struct AppConfig;
impl ConfigSchema for AppConfig {
fn schema() -> SchemaNode {
SchemaNode::new("/", "root", SchemaKind::Struct, "AppConfig").child(
"server",
SchemaNode::new("/server", "server", SchemaKind::Struct, "ServerConfig").child(
"port",
SchemaNode::new("/server/port", "port", SchemaKind::Integer, "u16"),
),
)
}
}
let schema = AppConfig::schema();
assert_eq!(schema.find("/server/port").unwrap().kind, SchemaKind::Integer);