Skip to main content

Config

Struct Config 

Source
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

Source

pub fn new() -> Self

Creates a new empty configuration

§Returns

Returns a new configuration instance

§Examples
use qubit_config::Config;

let config = Config::new();
assert!(config.is_empty());
Source

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"));
Source

pub fn description(&self) -> Option<&str>

Gets the configuration description

§Returns

Returns the configuration description as Option

Source

pub fn set_description(&mut self, description: Option<String>)

Sets the configuration description

§Parameters
  • description - Configuration description
§Returns

Nothing.

Source

pub fn is_enable_variable_substitution(&self) -> bool

Checks if variable substitution is enabled

§Returns

Returns true if variable substitution is enabled

Source

pub fn set_enable_variable_substitution(&mut self, enable: bool)

Sets whether to enable variable substitution

§Parameters
  • enable - Whether to enable
§Returns

Nothing.

Source

pub fn max_substitution_depth(&self) -> usize

Gets the maximum depth for variable substitution

§Returns

Returns the maximum depth value

Source

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");
Source

pub fn set_max_substitution_depth(&mut self, depth: usize)

Sets the maximum depth for variable substitution

§Parameters
  • depth - Maximum depth
§Returns

Nothing.

Source

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"));
Source

pub fn get_property(&self, name: &str) -> Option<&Property>

Gets a reference to a configuration item

§Parameters
  • name - Configuration item name
§Returns

Returns Option containing the configuration item

Source

pub fn get_property_mut(&mut self, name: &str) -> Option<&mut Property>

Gets a mutable reference to a configuration item

§Parameters
  • name - Configuration item name
§Returns

Returns mutable Option containing the configuration item

Source

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"));
Source

pub fn clear(&mut self)

Clears all configuration items

§Examples
use qubit_config::Config;

let mut config = Config::new();
config.set("port", 8080)?;
config.set("host", "localhost")?;

config.clear();
assert!(config.is_empty());
§Returns

Nothing.

Source

pub fn len(&self) -> usize

Gets the number of configuration items

§Returns

Returns the number of configuration items

Source

pub fn is_empty(&self) -> bool

Checks if the configuration is empty

§Returns

Returns true if the configuration contains no items

Source

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()));
Source

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 implement FromPropertyValue trait
§Parameters
  • name - Configuration item name
§Returns

The value of the specified type on success, or a ConfigError on failure.

§Errors
§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")?);
Source

pub fn get_or<T>(&self, name: &str, default: T) -> T
where 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 implement FromPropertyValue trait
§Parameters
  • name - Configuration item name
  • default - 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");
Source

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 implement FromPropertyValue trait
§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]);
Source

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 the values parameter
§Parameters
  • name - Configuration item name
  • values - Value to store; supports T, Vec<T>, &[T], and related forms accepted by MultiValues setters
§Returns

Returns Ok(()) on success, or an error on failure

§Errors
§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)
Source

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 the values parameter
§Parameters
  • name - Configuration item name
  • values - Values to append; supports the same forms as Self::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]);
Source

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");
Source

pub fn get_string_or(&self, name: &str, default: &str) -> String

Gets a string with substitution, or default if reading fails.

§Parameters
  • name - Configuration item name
  • default - Default value
§Returns

Returns the string value or default value

Source

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"]);
Source

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 name
  • default - 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"]);
Source

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();
Source

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);
}
Source

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);
Source

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."));
Source

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 - When true, removes prefix and the following dot from keys in the result; when false, 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"));
Source

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() returns false
  • Key exists but is empty/null → is_null() returns true
§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"));
Source

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 value
  • Ok(None) – key does not exist, or exists but is null/empty
  • Err(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);
Source

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 values
  • Ok(None) – key does not exist, or exists but is null/empty
  • Err(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);
Source

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);
Source

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(),
    ]),
);
Source

pub fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>

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 implement serde::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);
Source

pub fn properties_mut(&mut self) -> &mut HashMap<String, Property>

Returns a mutable reference to the internal properties map.

For advanced use cases, e.g. inserting null/empty properties that Self::set cannot represent alone.

§Returns

A mutable reference to the backing HashMap.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConfigReader for Config

Source§

fn is_enable_variable_substitution(&self) -> bool

Returns whether ${...} variable substitution is applied when reading string values. Read more
Source§

fn max_substitution_depth(&self) -> usize

Returns the maximum recursion depth allowed when resolving nested ${...} references. Read more
Source§

fn description(&self) -> Option<&str>

Returns the optional human-readable description attached to this configuration (the whole document; prefix views expose the same value as the underlying crate::Config).
Source§

fn get_property(&self, name: &str) -> Option<&Property>

Returns a reference to the raw Property for name, if present. Read more
Source§

fn len(&self) -> usize

Number of configuration entries visible to this reader (all keys for crate::Config; relative keys only for a ConfigPrefixView).
Source§

fn is_empty(&self) -> bool

Returns true when Self::len is zero.
Source§

fn keys(&self) -> Vec<String>

All keys visible to this reader (relative keys for a prefix view).
Source§

fn contains(&self, name: &str) -> bool

Returns whether a property exists for the given key. Read more
Source§

fn get<T>(&self, name: &str) -> ConfigResult<T>
where MultiValues: MultiValuesFirstGetter<T>,

Reads the first stored value for name and converts it to T. Read more
Source§

fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>
where MultiValues: MultiValuesGetter<T>,

Reads all stored values for name and converts each element to T. Read more
Source§

fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>
where MultiValues: MultiValuesFirstGetter<T>,

Gets an optional value with the same semantics as crate::Config::get_optional. Read more
Source§

fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>
where MultiValues: MultiValuesGetter<T>,

Gets an optional list with the same semantics as crate::Config::get_optional_list. Read more
Source§

fn contains_prefix(&self, prefix: &str) -> bool

Returns whether any key visible to this reader starts with prefix. Read more
Source§

fn iter_prefix<'a>( &'a self, prefix: &'a str, ) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>

Iterates (key, property) pairs for keys that start with prefix. Read more
Source§

fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (&'a str, &'a Property)> + 'a>

Iterates all (key, property) pairs visible to this reader (same scope as Self::keys).
Source§

fn is_null(&self, name: &str) -> bool

Returns 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>

Extracts a subtree as a new 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>

Deserializes the subtree at prefix with serde (same as crate::Config::deserialize; on a prefix view, prefix is relative).
Source§

fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'_>

Creates a read-only prefix view; relative keys resolve under prefix. Read more
Source§

fn get_or<T>(&self, name: &str, default: T) -> T
where MultiValues: MultiValuesFirstGetter<T>,

Gets a value or default if the key is missing or conversion fails (same as crate::Config::get_or).
Source§

fn resolve_key(&self, name: &str) -> String

Resolves name into the canonical key path against the root crate::Config. Read more
Source§

fn get_string(&self, name: &str) -> ConfigResult<String>

Gets a string value, applying variable substitution when enabled. Read more
Source§

fn get_string_or(&self, name: &str, default: &str) -> String

Gets a string value with substitution, or default if lookup or substitution fails. Read more
Source§

fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>

Gets all string values for name, applying substitution to each element when enabled. Read more
Source§

fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>

Gets a string list with substitution, or copies default if lookup fails. Read more
Source§

fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>

Gets an optional string with the same three-way semantics as crate::Config::get_optional_string. Read more
Source§

fn get_optional_string_list( &self, name: &str, ) -> ConfigResult<Option<Vec<String>>>

Gets an optional string list with per-element substitution when enabled. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Creates a new default configuration

§Returns

Returns a new configuration instance

§Examples
use qubit_config::Config;

let config = Config::default();
assert!(config.is_empty());
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,