Skip to main content

Crate hiver_config

Crate hiver_config 

Source
Expand description

Hiver Config - Configuration management module Hiver配置 - 配置管理模块

§Equivalent to Spring Boot / 等价于 Spring Boot

  • @ConfigurationProperties - PropertiesConfig
  • @Value - Value extractor
  • Environment - Environment
  • PropertySource - PropertySource
  • @Profile - Profile
  • ConfigFileApplicationListener - 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 PropertiesConfig for a type 为类型实现PropertiesConfig的宏
properties_config
Macro to create a properties config struct 创建属性配置结构的宏

Structs§

ActiveProfiles
Active profiles manager 活动配置文件管理器
Config
Main configuration structure 主配置结构
ConfigBuilder
Configuration builder 配置构建器
ConfigChangeEvent
Event fired when a configuration property changes. 当配置属性发生更改时触发的事件。
ConfigEncryptor
Encryptor for configuration values. 配置值加密器。
ConfigLoader
Configuration loader 配置加载器
ConfigLoaderBuilder
Configuration loader builder 配置加载器构建器
ConfigWatcher
ConfigWatcher — watches config sources for changes. ConfigWatcher — 监视配置源的更改。
Environment
Environment interface 环境接口
Profile
Environment profile 环境配置文件
PropertiesConfigRegistry
Properties configuration registry 属性配置注册表
PropertySource
Property source 属性源
PropertySourceBuilder
Property source builder 属性源构建器
RefreshScope
RefreshScope — marks beans that should be refreshed when config changes. RefreshScope — 标记在配置更改时应刷新的 bean。
Refreshable
A wrapper that auto-refreshes its value when configuration changes. 在配置更改时自动刷新其值的包装器。
ValueExtractor
Value extractor for @Value annotation equivalent @Value注解等价物的值提取器
Watcher
File watcher for configuration hot reload 配置热重载的文件监视器

Enums§

ConfigError
Configuration error type 配置错误类型
EncryptError
Encryption errors. 加密错误。
FileFormat
Configuration file format 配置文件格式
PropertySourceType
Property source type 属性源类型
ReloadStrategy
Configuration reload strategy 配置重新加载策略
Value
Configuration value wrapper 配置值包装器

Constants§

VERSION
Version of the config module

Traits§

PropertiesConfig
Properties configuration trait 属性配置trait

Type Aliases§

ConfigResult
Configuration result type 配置结果类型