Expand description
Hiver Config - Configuration management module Hiver配置 - 配置管理模块
§Equivalent to Spring Boot / 等价于 Spring Boot
@ConfigurationProperties-PropertiesConfig@Value- Value extractorEnvironment- EnvironmentPropertySource-PropertySource@Profile- ProfileConfigFileApplicationListener-ConfigLoader
§Example / 示例
ⓘ
use hiver_config::{Config, PropertiesConfig};
use serde::Deserialize;
#[derive(PropertiesConfig, Deserialize)]
#[prefix = "app.datasource"]
struct DataSourceConfig {
url: String,
username: String,
password: String,
}
#[derive(PropertiesConfig, Deserialize)]
#[prefix = "server"]
struct ServerConfig {
port: u16,
host: String,
}
let config = Config::load().unwrap();
let server = config.get::<ServerConfig>().unwrap();Modules§
- prelude
- Re-exports of commonly used types 常用类型的重新导出
Macros§
- impl_
properties_ config - Macro to implement
PropertiesConfigfor a type为类型实现PropertiesConfig的宏 - properties_
config - Macro to create a properties config struct 创建属性配置结构的宏
Structs§
- Active
Profiles - Active profiles manager 活动配置文件管理器
- Config
- Main configuration structure 主配置结构
- Config
Builder - Configuration builder 配置构建器
- Config
Change Event - Event fired when a configuration property changes. 当配置属性发生更改时触发的事件。
- Config
Encryptor - Encryptor for configuration values. 配置值加密器。
- Config
Loader - Configuration loader 配置加载器
- Config
Loader Builder - Configuration loader builder 配置加载器构建器
- Config
Watcher - ConfigWatcher — watches config sources for changes. ConfigWatcher — 监视配置源的更改。
- Environment
- Environment interface 环境接口
- Profile
- Environment profile 环境配置文件
- Properties
Config Registry - Properties configuration registry 属性配置注册表
- Property
Source - Property source 属性源
- Property
Source Builder - Property source builder 属性源构建器
- Refresh
Scope - RefreshScope — marks beans that should be refreshed when config changes. RefreshScope — 标记在配置更改时应刷新的 bean。
- Refreshable
- A wrapper that auto-refreshes its value when configuration changes. 在配置更改时自动刷新其值的包装器。
- Value
Extractor - Value extractor for @Value annotation equivalent @Value注解等价物的值提取器
- Watcher
- File watcher for configuration hot reload 配置热重载的文件监视器
Enums§
- Config
Error - Configuration error type 配置错误类型
- Encrypt
Error - Encryption errors. 加密错误。
- File
Format - Configuration file format 配置文件格式
- Property
Source Type - Property source type 属性源类型
- Reload
Strategy - Configuration reload strategy 配置重新加载策略
- Value
- Configuration value wrapper 配置值包装器
Constants§
- VERSION
- Version of the config module
Traits§
- Properties
Config - Properties configuration trait 属性配置trait
Type Aliases§
- Config
Result - Configuration result type 配置结果类型