pub struct Config { /* private fields */ }Expand description
Configuration Manager
Manages a set of configuration properties with type-safe read/write interfaces.
§Features
- Supports multiple data types
- Supports variable substitution (
${var_name}format) - Supports configuration merging
- Supports final value protection
- Thread-safe (when wrapped in
Arc<RwLock<Config>>)
§Examples
use qubit_config::Config;
let mut config = Config::new();
// Set configuration values (type inference)
config.set("port", 8080)?; // inferred as i32
config.set("host", "localhost")?;
// &str is converted to String
config.set("debug", true)?; // inferred as bool
config.set("timeout", 30.5)?; // inferred as f64
config.set("code", 42u8)?; // inferred as u8
// Set multiple values (type inference)
config.set("ports", vec![8080, 8081, 8082])?; // inferred as i32
config.set("hosts", &["host1", "host2"])?;
// &str elements are converted
// Read configuration values (type inference)
let port: i32 = config.get("port")?;
let host: String = config.get("host")?;
let debug: bool = config.get("debug")?;
let code: u8 = config.get("code")?;
// Read configuration values (turbofish)
let port = config.get::<i32>("port")?;
// Read configuration value or use default
let timeout: u64 = config.get_or("timeout", 30);§Author
Haixing Hu
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_description(description: &str) -> Self
pub fn with_description(description: &str) -> Self
Creates a configuration with description
§Parameters
description- Configuration description
§Returns
Returns a new configuration instance
§Examples
use qubit_config::Config;
let config = Config::with_description("Server Configuration");
assert_eq!(config.description(), Some("Server Configuration"));Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Sourcepub fn set_description(&mut self, description: Option<String>)
pub fn set_description(&mut self, description: Option<String>)
Sourcepub fn is_enable_variable_substitution(&self) -> bool
pub fn is_enable_variable_substitution(&self) -> bool
Checks if variable substitution is enabled
§Returns
Returns true if variable substitution is enabled
Sourcepub fn set_enable_variable_substitution(&mut self, enable: bool)
pub fn set_enable_variable_substitution(&mut self, enable: bool)
Sourcepub fn max_substitution_depth(&self) -> usize
pub fn max_substitution_depth(&self) -> usize
Sourcepub fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'_>
pub fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'_>
Creates a read-only prefix view using crate::ConfigPrefixView.
§Parameters
prefix- Prefix
§Returns
Returns a read-only prefix view
§Examples
use qubit_config::{Config, ConfigReader};
let config = Config::new();
config.set("server.port", 8080)?;
config.set("server.host", "localhost")?;
let server = config.prefix_view("server");
assert_eq!(server.get("port")?, 8080);
assert_eq!(server.get("host")?, "localhost");Sourcepub fn set_max_substitution_depth(&mut self, depth: usize)
pub fn set_max_substitution_depth(&mut self, depth: usize)
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Checks if the configuration contains an item with the specified name
§Parameters
name- Configuration item name
§Returns
Returns true if the configuration item exists
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?;
assert!(config.contains("port"));
assert!(!config.contains("host"));Sourcepub fn get_property(&self, name: &str) -> Option<&Property>
pub fn get_property(&self, name: &str) -> Option<&Property>
Sourcepub fn get_property_mut(&mut self, name: &str) -> Option<&mut Property>
pub fn get_property_mut(&mut self, name: &str) -> Option<&mut Property>
Sourcepub fn remove(&mut self, name: &str) -> Option<Property>
pub fn remove(&mut self, name: &str) -> Option<Property>
Removes a configuration item
§Parameters
name- Configuration item name
§Returns
Returns the removed configuration item, or None if it doesn’t exist
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?;
let removed = config.remove("port");
assert!(removed.is_some());
assert!(!config.contains("port"));Sourcepub fn keys(&self) -> Vec<String>
pub fn keys(&self) -> Vec<String>
Gets all configuration item names
§Returns
Returns a Vec of configuration item names
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?;
config.set("host", "localhost")?;
let keys = config.keys();
assert_eq!(keys.len(), 2);
assert!(keys.contains(&"port".to_string()));
assert!(keys.contains(&"host".to_string()));Sourcepub fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
pub fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
Gets a configuration value.
Core read API with type inference.
§Note
This method does not perform variable substitution for string types. If
you need variable substitution, use Self::get_string.
§Type Parameters
T- Target type, must implementFromPropertyValuetrait
§Parameters
name- Configuration item name
§Returns
The value of the specified type on success, or a ConfigError on
failure.
§Errors
ConfigError::PropertyNotFoundif the key does not existConfigError::PropertyHasNoValueif the property has no valueConfigError::TypeMismatchif the type does not match
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?;
config.set("host", "localhost")?;
// Method 1: Type inference
let port: i32 = config.get("port")?;
let host: String = config.get("host")?;
// Method 2: Turbofish
let port = config.get::<i32>("port")?;
let host = config.get::<String>("host")?;
// Method 3: Inference from usage
fn start_server(port: i32, host: String) { }
start_server(config.get("port")?, config.get("host")?);Sourcepub fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
pub fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
Gets a configuration value or returns a default value
Returns default if the key is missing or if reading the value fails.
§Type Parameters
T- Target type, must implementFromPropertyValuetrait
§Parameters
name- Configuration item namedefault- Default value
§Returns
Returns the configuration value or default value
§Examples
use qubit_config::Config;
let config = Config::new();
let port: i32 = config.get_or("port", 8080);
let host: String = config.get_or("host", "localhost".to_string());
assert_eq!(port, 8080);
assert_eq!(host, "localhost");Sourcepub fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
pub fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
Gets a list of configuration values
Gets all values of a configuration item (multi-value configuration).
§Type Parameters
T- Target type, must implementFromPropertyValuetrait
§Parameters
name- Configuration item name
§Returns
Returns a list of values on success, or an error on failure
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("ports", vec![8080, 8081, 8082])?;
let ports: Vec<i32> = config.get_list("ports")?;
assert_eq!(ports, vec![8080, 8081, 8082]);Sourcepub fn set<S>(&mut self, name: &str, values: S) -> ConfigResult<()>where
S: for<'a> MultiValuesSetArg<'a>,
<S as MultiValuesSetArg<'static>>::Item: Clone,
MultiValues: MultiValuesSetter<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetterSlice<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSingleSetter<<S as MultiValuesSetArg<'static>>::Item>,
pub fn set<S>(&mut self, name: &str, values: S) -> ConfigResult<()>where
S: for<'a> MultiValuesSetArg<'a>,
<S as MultiValuesSetArg<'static>>::Item: Clone,
MultiValues: MultiValuesSetter<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetterSlice<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSingleSetter<<S as MultiValuesSetArg<'static>>::Item>,
Sets a configuration value
This is the core method for setting configuration values, supporting type inference.
§Type Parameters
T- Element type, automatically inferred from thevaluesparameter
§Parameters
name- Configuration item namevalues- Value to store; supportsT,Vec<T>,&[T], and related forms accepted byMultiValuessetters
§Returns
Returns Ok(()) on success, or an error on failure
§Errors
ConfigError::PropertyIsFinalif the property is marked final
§Examples
use qubit_config::Config;
let mut config = Config::new();
// Set single values (type auto-inference)
config.set("port", 8080)?; // T inferred as i32
config.set("host", "localhost")?;
// T inferred as String; &str is converted
config.set("debug", true)?; // T inferred as bool
config.set("timeout", 30.5)?; // T inferred as f64
// Set multiple values (type auto-inference)
config.set("ports", vec![8080, 8081, 8082])?; // T inferred as i32
config.set("hosts", &["host1", "host2"])?;
// T inferred as &str (then converted)Sourcepub fn add<S>(&mut self, name: &str, values: S) -> ConfigResult<()>where
S: for<'a> MultiValuesAddArg<'a, Item = <S as MultiValuesSetArg<'static>>::Item> + for<'a> MultiValuesSetArg<'a>,
<S as MultiValuesSetArg<'static>>::Item: Clone,
MultiValues: MultiValuesAdder<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesMultiAdder<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetter<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetterSlice<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSingleSetter<<S as MultiValuesSetArg<'static>>::Item>,
pub fn add<S>(&mut self, name: &str, values: S) -> ConfigResult<()>where
S: for<'a> MultiValuesAddArg<'a, Item = <S as MultiValuesSetArg<'static>>::Item> + for<'a> MultiValuesSetArg<'a>,
<S as MultiValuesSetArg<'static>>::Item: Clone,
MultiValues: MultiValuesAdder<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesMultiAdder<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetter<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSetterSlice<<S as MultiValuesSetArg<'static>>::Item> + MultiValuesSingleSetter<<S as MultiValuesSetArg<'static>>::Item>,
Adds configuration values
Adds values to an existing configuration item (multi-value properties).
§Type Parameters
T- Element type, automatically inferred from thevaluesparameter
§Parameters
name- Configuration item namevalues- Values to append; supports the same forms asSelf::set
§Returns
Returns Ok(()) on success, or an error on failure
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?; // Set initial value
config.add("port", 8081)?; // Add single value
config.add("port", vec![8082, 8083])?; // Add multiple values
config.add("port", &[8084, 8085])?; // Add slice
let ports: Vec<i32> = config.get_list("port")?;
assert_eq!(ports, vec![8080, 8081, 8082, 8083, 8084, 8085]);Sourcepub fn get_string(&self, name: &str) -> ConfigResult<String>
pub fn get_string(&self, name: &str) -> ConfigResult<String>
Gets a string configuration value (with variable substitution)
If variable substitution is enabled, replaces ${var_name} placeholders
in the stored string.
§Parameters
name- Configuration item name
§Returns
Returns the string value on success, or an error on failure
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("base_url", "http://localhost")?;
config.set("api_url", "${base_url}/api")?;
let api_url = config.get_string("api_url")?;
assert_eq!(api_url, "http://localhost/api");Sourcepub fn get_string_or(&self, name: &str, default: &str) -> String
pub fn get_string_or(&self, name: &str, default: &str) -> String
Sourcepub fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
pub fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
Gets a list of string configuration values (with variable substitution)
If variable substitution is enabled, runs it on each list element
(same ${var_name} rules as Self::get_string).
§Parameters
name- Configuration item name
§Returns
Returns a list of strings on success, or an error on failure
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("base_path", "/opt/app")?;
config.set("paths", vec!["${base_path}/bin", "${base_path}/lib"])?;
let paths = config.get_string_list("paths")?;
assert_eq!(paths, vec!["/opt/app/bin", "/opt/app/lib"]);Sourcepub fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
pub fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
Gets a list of string configuration values or returns a default value (with variable substitution)
§Parameters
name- Configuration item namedefault- Default value (can be array slice or vec)
§Returns
Returns the list of strings or default value
§Examples
use qubit_config::Config;
let config = Config::new();
// Using array slice
let paths = config.get_string_list_or("paths", &["/default/path"]);
assert_eq!(paths, vec!["/default/path"]);
// Using vec
let paths = config.get_string_list_or("paths", &vec!["path1", "path2"]);
assert_eq!(paths, vec!["path1", "path2"]);Sourcepub fn merge_from_source(
&mut self,
source: &dyn ConfigSource,
) -> ConfigResult<()>
pub fn merge_from_source( &mut self, source: &dyn ConfigSource, ) -> ConfigResult<()>
Merges configuration from a ConfigSource
Loads all key-value pairs from the given source and merges them into this configuration. Existing non-final properties are overwritten; final properties are preserved and cause an error if the source tries to overwrite them.
§Parameters
source- The configuration source to load from
§Returns
Returns Ok(()) on success, or a ConfigError on failure
§Examples
use qubit_config::Config;
use qubit_config::source::{
CompositeConfigSource, ConfigSource,
EnvConfigSource, TomlConfigSource,
};
let mut composite = CompositeConfigSource::new();
composite.add(TomlConfigSource::from_file("config.toml"));
composite.add(EnvConfigSource::with_prefix("APP_"));
let mut config = Config::new();
config.merge_from_source(&composite).unwrap();Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Property)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Property)>
Iterates over all configuration entries as (key, &Property) pairs.
§Returns
An iterator yielding (&str, &Property) tuples.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("host", "localhost")?;
config.set("port", 8080)?;
for (key, prop) in config.iter() {
println!("{} = {:?}", key, prop);
}Sourcepub fn iter_prefix<'a>(
&'a self,
prefix: &'a str,
) -> impl Iterator<Item = (&'a str, &'a Property)>
pub fn iter_prefix<'a>( &'a self, prefix: &'a str, ) -> impl Iterator<Item = (&'a str, &'a Property)>
Iterates over all configuration entries whose key starts with prefix.
§Parameters
prefix- The key prefix to filter by (e.g.,"http.")
§Returns
An iterator of (&str, &Property) whose keys start with prefix.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("http.host", "localhost")?;
config.set("http.port", 8080)?;
config.set("db.host", "dbhost")?;
let http_entries: Vec<_> = config.iter_prefix("http.").collect();
assert_eq!(http_entries.len(), 2);Sourcepub fn contains_prefix(&self, prefix: &str) -> bool
pub fn contains_prefix(&self, prefix: &str) -> bool
Returns true if any configuration key starts with prefix.
§Parameters
prefix- The key prefix to check
§Returns
true if at least one key starts with prefix, false otherwise.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("http.host", "localhost")?;
assert!(config.contains_prefix("http."));
assert!(!config.contains_prefix("db."));Sourcepub fn subconfig(
&self,
prefix: &str,
strip_prefix: bool,
) -> ConfigResult<Config>
pub fn subconfig( &self, prefix: &str, strip_prefix: bool, ) -> ConfigResult<Config>
Extracts a sub-configuration for keys matching prefix.
§Parameters
prefix- The key prefix to extract (e.g.,"http")strip_prefix- Whentrue, removesprefixand the following dot from keys in the result; whenfalse, keys are copied unchanged.
§Returns
A new Config containing only the matching entries.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("http.host", "localhost")?;
config.set("http.port", 8080)?;
config.set("db.host", "dbhost")?;
let http_config = config.subconfig("http", true)?;
assert!(http_config.contains("host"));
assert!(http_config.contains("port"));
assert!(!http_config.contains("db.host"));Sourcepub fn is_null(&self, name: &str) -> bool
pub fn is_null(&self, name: &str) -> bool
Returns true if the property exists but has no value (empty / null).
This distinguishes between:
- Key does not exist →
contains()returnsfalse - Key exists but is empty/null →
is_null()returnstrue
§Parameters
name- Configuration item name
§Returns
true if the property exists and has no values (is empty).
§Examples
use qubit_config::{Config, Property};
use qubit_value::MultiValues;
use qubit_common::DataType;
let mut config = Config::new();
config.properties_mut().insert(
"nullable".to_string(),
Property::with_value(
"nullable",
MultiValues::Empty(DataType::String),
),
);
assert!(config.is_null("nullable"));
assert!(!config.is_null("missing"));Sourcepub fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
pub fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
Gets an optional configuration value.
Distinguishes between three states:
Ok(Some(value))– key exists and has a valueOk(None)– key does not exist, or exists but is null/emptyErr(e)– key exists and has a value, but conversion failed
§Type Parameters
T- Target type
§Parameters
name- Configuration item name
§Returns
Ok(Some(value)), Ok(None), or Err as described above.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("port", 8080)?;
let port: Option<i32> = config.get_optional("port")?;
assert_eq!(port, Some(8080));
let missing: Option<i32> = config.get_optional("missing")?;
assert_eq!(missing, None);Sourcepub fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
pub fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
Gets an optional list of configuration values.
See also Self::get_optional_string_list for optional string lists
with variable substitution.
Distinguishes between three states:
Ok(Some(vec))– key exists and has valuesOk(None)– key does not exist, or exists but is null/emptyErr(e)– key exists and has values, but conversion failed
§Type Parameters
T- Target element type
§Parameters
name- Configuration item name
§Returns
Ok(Some(vec)), Ok(None), or Err as described above.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("ports", vec![8080, 8081])?;
let ports: Option<Vec<i32>> = config.get_optional_list("ports")?;
assert_eq!(ports, Some(vec![8080, 8081]));
let missing: Option<Vec<i32>> = config.get_optional_list("missing")?;
assert_eq!(missing, None);Sourcepub fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
pub fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
Gets an optional string (with variable substitution when enabled).
Same semantics as Self::get_optional, but values are read via
Self::get_string, so ${...} substitution applies when enabled.
§Parameters
name- Configuration item name
§Returns
Ok(Some(s)), Ok(None), or Err as for Self::get_optional.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("base", "http://localhost")?;
config.set("api", "${base}/api")?;
let api = config.get_optional_string("api")?;
assert_eq!(api.as_deref(), Some("http://localhost/api"));
let missing = config.get_optional_string("missing")?;
assert_eq!(missing, None);Sourcepub fn get_optional_string_list(
&self,
name: &str,
) -> ConfigResult<Option<Vec<String>>>
pub fn get_optional_string_list( &self, name: &str, ) -> ConfigResult<Option<Vec<String>>>
Gets an optional string list (substitution per element when enabled).
Same semantics as Self::get_optional_list, but elements use
Self::get_string_list (same ${...} rules as Self::get_string).
§Parameters
name- Configuration item name
§Returns
Ok(Some(vec)), Ok(None), or Err like Self::get_optional_list.
§Examples
use qubit_config::Config;
let mut config = Config::new();
config.set("root", "/opt/app")?;
config.set("paths", vec!["${root}/bin", "${root}/lib"])?;
let paths = config.get_optional_string_list("paths")?;
assert_eq!(
paths,
Some(vec![
"/opt/app/bin".to_string(),
"/opt/app/lib".to_string(),
]),
);Sourcepub fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
pub fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
Deserializes the subtree at prefix into T using serde.
Keys under prefix (prefix and trailing dot removed) form a flat map
for serde, for example:
#[derive(serde::Deserialize)]
struct HttpOptions {
host: String,
port: u16,
}can be populated from config keys http.host and http.port by calling
config.deserialize::<HttpOptions>("http").
§Type Parameters
T- Target type, must implementserde::de::DeserializeOwned
§Parameters
prefix- Key prefix for the struct fields (""means the root map)
§Returns
The deserialized T, or a ConfigError::DeserializeError on failure.
§Examples
use qubit_config::Config;
use serde::Deserialize;
#[derive(Deserialize, Debug, PartialEq)]
struct Server {
host: String,
port: i32,
}
let mut config = Config::new();
config.set("server.host", "localhost")?;
config.set("server.port", 8080)?;
let server: Server = config.deserialize("server")?;
assert_eq!(server.host, "localhost");
assert_eq!(server.port, 8080);Trait Implementations§
Source§impl ConfigReader for Config
impl ConfigReader for Config
Source§fn is_enable_variable_substitution(&self) -> bool
fn is_enable_variable_substitution(&self) -> bool
${...} variable substitution is applied when reading
string values. Read moreSource§fn max_substitution_depth(&self) -> usize
fn max_substitution_depth(&self) -> usize
${...} references. Read moreSource§fn description(&self) -> Option<&str>
fn description(&self) -> Option<&str>
crate::Config).Source§fn len(&self) -> usize
fn len(&self) -> usize
crate::Config; relative keys only for a ConfigPrefixView).Source§fn keys(&self) -> Vec<String>
fn keys(&self) -> Vec<String>
Source§fn contains(&self, name: &str) -> bool
fn contains(&self, name: &str) -> bool
Source§fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
Source§fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
Source§fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
crate::Config::get_optional. Read moreSource§fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
crate::Config::get_optional_list. Read moreSource§fn contains_prefix(&self, prefix: &str) -> bool
fn contains_prefix(&self, prefix: &str) -> bool
prefix. Read moreSource§fn iter_prefix<'a>(
&'a self,
prefix: &'a str,
) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>
fn iter_prefix<'a>( &'a self, prefix: &'a str, ) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>
Source§fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>
(key, property) pairs visible to this reader (same scope
as Self::keys).Source§fn is_null(&self, name: &str) -> bool
fn is_null(&self, name: &str) -> bool
true if the key exists and the property has no values (same
as crate::Config::is_null).Source§fn subconfig(&self, prefix: &str, strip_prefix: bool) -> ConfigResult<Config>
fn subconfig(&self, prefix: &str, strip_prefix: bool) -> ConfigResult<Config>
Config (same semantics as
crate::Config::subconfig; on a prefix view, prefix is relative to
the view).Source§fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
prefix with serde (same as
crate::Config::deserialize; on a prefix view, prefix is relative).Source§fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'_>
fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'_>
prefix. Read moreSource§fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
default if the key is missing or conversion fails (same
as crate::Config::get_or).Source§fn resolve_key(&self, name: &str) -> String
fn resolve_key(&self, name: &str) -> String
Source§fn get_string(&self, name: &str) -> ConfigResult<String>
fn get_string(&self, name: &str) -> ConfigResult<String>
Source§fn get_string_or(&self, name: &str, default: &str) -> String
fn get_string_or(&self, name: &str, default: &str) -> String
default if lookup or
substitution fails. Read moreSource§fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
name, applying substitution to each element
when enabled. Read moreSource§fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
default if lookup
fails. Read moreSource§fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
crate::Config::get_optional_string. Read more