

























GitHub 仓库地址:https://github.com/fawdlstty/faml
FAML 是一种扩展自 TOML 的动态配置语言,专为需要运行时配置计算和更新的场景设计。它保留了 TOML 的简洁语法,同时增加了动态表达式、条件配置和运行时可变性等高级特性。
| 特性 | TOML | KCL | PKL | FAML |
|---|---|---|---|---|
| 语法风格 | TOML 风格 | JSON 风格 | 结构体风格 | TOML 风格 |
| 动态表达式 | ❌ | ✅ | ✅ | ✅ |
| 条件配置 | ❌ | ✅ | ✅ | ✅ |
| 运行时修改 | ❌ | ❌ | ❌ | ✅ |
| 特殊数据类型 | ❌ | ✅ | ✅ | ✅ |
[server]
port = 8080
host = "localhost"
[database]
host = "localhost"
port = 5432
connection_string = $"postgresql://{host}:{port}/mydb"
[app]
env = "production"
@if env == "development"
log_level = "debug"
@if env == "production"
log_level = "error"
[cache]
ttl = 5 minutes
max_size = 100 MB
[network]
timeout = 30 seconds
buffer_size = 4 KB
[user]
age = 25
is_adult = age >= 18
welcome_message = is_adult ? $"Welcome, adult user!" : $"Welcome, young user!"
let mut config = FamlExpr::from_str(config_str)?;
config["server"]["port"].set_int(9000); // 动态修改端口
let connection_string = config["database"]["connection_string"].evaluate()?.as_str(); // 自动更新连接字符串
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。