pub struct Environment { /* private fields */ }Expand description
Environment interface 环境接口
Equivalent to Spring’s Environment interface.
等价于Spring的Environment接口。
Provides access to configuration properties and profiles. 提供对配置属性和配置文件的访问。
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn add_property_source(&self, source: PropertySource)
pub fn add_property_source(&self, source: PropertySource)
Add a property source 添加属性源
Sourcepub fn add_property_source_first(&self, source: PropertySource)
pub fn add_property_source_first(&self, source: PropertySource)
Add a property source as first (highest priority) 添加属性源到第一个(最高优先级)
Sourcepub fn get_property(&self, key: &str) -> Option<Value>
pub fn get_property(&self, key: &str) -> Option<Value>
Get a property value 获取属性值
Sourcepub fn get_property_as<T>(&self, key: &str) -> ConfigResult<T>where
T: DeserializeOwned,
pub fn get_property_as<T>(&self, key: &str) -> ConfigResult<T>where
T: DeserializeOwned,
Get a property as a specific type 获取特定类型的属性
Sourcepub fn get_required_property(&self, key: &str) -> ConfigResult<Value>
pub fn get_required_property(&self, key: &str) -> ConfigResult<Value>
Get a required property 获取必需属性
Sourcepub fn get_required_property_as<T>(&self, key: &str) -> ConfigResult<T>where
T: DeserializeOwned,
pub fn get_required_property_as<T>(&self, key: &str) -> ConfigResult<T>where
T: DeserializeOwned,
Get a required property as a specific type 获取特定类型的必需属性
Sourcepub fn contains_property(&self, key: &str) -> bool
pub fn contains_property(&self, key: &str) -> bool
Check if a property exists 检查属性是否存在
Sourcepub fn resolve_placeholders(&self, input: &str) -> String
pub fn resolve_placeholders(&self, input: &str) -> String
Resolve placeholders in a string (e.g., ${some.property}) 解析字符串中的占位符(例如 ${some.property})
Sourcepub fn get_active_profiles(&self) -> Vec<Profile>
pub fn get_active_profiles(&self) -> Vec<Profile>
Get active profiles 获取活动配置文件
Sourcepub fn set_active_profiles(&self, profiles: Vec<Profile>)
pub fn set_active_profiles(&self, profiles: Vec<Profile>)
Set active profiles 设置活动配置文件
Sourcepub fn add_active_profile(&self, profile: Profile)
pub fn add_active_profile(&self, profile: Profile)
Add an active profile 添加活动配置文件
Sourcepub fn accepts_profiles(&self, profiles: &[Profile]) -> bool
pub fn accepts_profiles(&self, profiles: &[Profile]) -> bool
Check if a profile is active 检查配置文件是否活动
Sourcepub fn get_property_sources(&self) -> Vec<PropertySource>
pub fn get_property_sources(&self) -> Vec<PropertySource>
Get all property sources 获取所有属性源
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Environment
impl Debug for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnsafeUnpin for Environment
impl UnwindSafe for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more