Crates.io | config-plus |
lib.rs | config-plus |
version | 0.1.15 |
created_at | 2025-06-23 09:02:02.137451+00 |
updated_at | 2025-08-12 06:10:02.0565+00 |
description | 对config库的增强 |
homepage | |
repository | https://gitee.com/itao007/config-plus.git |
max_upload_size | |
id | 1722646 |
size | 56,493 |
为结构体生成一个config
方法,调用该方法可以读取配置文件中的属性
使用方式
#[derive(Debug, Deserialize, Configuration)]
#[properties(prefix = "push.file", file(path = "application.yml", require = true))]
#[properties]
可以配置的属性
优先级: http > environment > file
示例
#[derive(Debug, Deserialize, Configuration)]
#[properties(
prefix = "push.file",
file(path = "application.yml", require = true),
http(url = "http://127.0.0.1:8080/toml", format = "toml"),
environment = true
)]
#[serde(rename_all(deserialize = "camelCase"))]
struct PushFile {
enable: u8,
app_id: String,
app_key: String,
master_secret: String,
package_name: String,
}
let config = PushFile::config();