| Crates.io | config-plus |
| lib.rs | config-plus |
| version | 0.2.2 |
| created_at | 2025-06-23 09:02:02.137451+00 |
| updated_at | 2025-12-31 07:55:48.208566+00 |
| description | 对config库的增强 |
| homepage | |
| repository | https://gitee.com/itao007/config-plus.git |
| max_upload_size | |
| id | 1722646 |
| size | 58,303 |
为结构体生成一个config方法,调用该方法可以读取配置文件中的属性
使用方式
#[derive(Debug, Deserialize, Configuration)]
#[config(prefix = "push.file", file(path = "application.yml", require = true), env(name = "CONFIG_PATH", require = true))]
#[config]可以配置的属性
优先级: http > environment > env > file
示例
#[derive(Debug, Deserialize, Configuration)]
#[config(
prefix = "push.file",
file(path = "application.yml", require, format = "yml"),
env(name = "CONFIG_PATH"),
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();