pub struct ConfigSchema { /* private fields */ }Expand description
配置 schema:多字段校验定义
Implementations§
Source§impl ConfigSchema
impl ConfigSchema
Sourcepub fn add_field(self, field: FieldSchema) -> Self
pub fn add_field(self, field: FieldSchema) -> Self
添加字段定义(链式)
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
字段数
Sourcepub fn validate(
&self,
config: &HashMap<String, String>,
) -> ConfigValidationReport
pub fn validate( &self, config: &HashMap<String, String>, ) -> ConfigValidationReport
校验配置 HashMap
Sourcepub fn validate_and_fill_defaults(
&self,
config: &HashMap<String, String>,
) -> (HashMap<String, String>, ConfigValidationReport)
pub fn validate_and_fill_defaults( &self, config: &HashMap<String, String>, ) -> (HashMap<String, String>, ConfigValidationReport)
校验并填充默认值(返回新 config)
Sourcepub fn validate_env(&self) -> ConfigValidationReport
pub fn validate_env(&self) -> ConfigValidationReport
从环境变量读取配置并校验
对每个字段,先查 env var,再查默认值,最后校验。
Sourcepub fn field_names(&self) -> Vec<&str>
pub fn field_names(&self) -> Vec<&str>
返回所有字段名
Trait Implementations§
Source§impl Clone for ConfigSchema
impl Clone for ConfigSchema
Source§fn clone(&self) -> ConfigSchema
fn clone(&self) -> ConfigSchema
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 ConfigSchema
impl Debug for ConfigSchema
Source§impl Default for ConfigSchema
impl Default for ConfigSchema
Source§fn default() -> ConfigSchema
fn default() -> ConfigSchema
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConfigSchema
impl RefUnwindSafe for ConfigSchema
impl Send for ConfigSchema
impl Sync for ConfigSchema
impl Unpin for ConfigSchema
impl UnsafeUnpin for ConfigSchema
impl UnwindSafe for ConfigSchema
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