pub struct ConfigBuilder { /* private fields */ }
Expand description

The builder for Config structure.

Implementations§

source§

impl ConfigBuilder

source

pub fn append_parser<P>(self, parser: P) -> Selfwhere P: Parse + 'static,

Append a parser to Config. First appended parser will have highest priority during (re)load merge, the last one will have lowest priority.

Example
use irx_config::parsers::{env, json};
use irx_config::ConfigBuilder;

let config = ConfigBuilder::default()
    .append_parser(
        json::ParserBuilder::default()
            .default_path("config.json")
            .build()?,
    )
    .append_parser(
        env::ParserBuilder::default()
            .default_prefix("APP_")
            .build()?,
    )
    .load()?;
source

pub fn sealed_suffix<S>(self, suffix: S) -> Selfwhere S: Into<String>,

Set suffix for keys to mark them as a secret value which will be obfuscated during display/debugging output. If not set then all values will be displayed as is.

Example
use irx_config::parsers::env;
use irx_config::ConfigBuilder;

let config = ConfigBuilder::default()
    .append_parser(
        env::ParserBuilder::default()
            .default_prefix("APP_")
            .build()?,
    )
    .sealed_suffix("_sealed_")
    .load()?;
source

pub fn keys_delimiter<D>(self, delim: D) -> Selfwhere D: Into<String>,

Set default key level delimiter. Default is DEFAULT_KEYS_SEPARATOR.

Example
use clap::app_from_crate;
use irx_config::parsers::cmd;
use irx_config::ConfigBuilder;

let app = app_from_crate!();

let config = ConfigBuilder::default()
    .append_parser(cmd::ParserBuilder::new(app).build()?)
    .keys_delimiter("/")
    .load()?;
source

pub fn merge_case(self, case: MergeCase) -> Self

Set merge case mode for a keys (see MergeCase). Default is MergeCase::Auto.

source

pub fn load(self) -> Result<Config>

Load all data from all previously appended parsers, merge data according to appended order and return Config.

Errors

If any errors will occur during parsing/merging then error will be returned.

source

pub fn load_one<P>(parser: P) -> Result<Config>where P: Parse + 'static,

Load data from one parser and return Config.

Errors

If any errors will occur during parsing/merging then error will be returned.

source

pub fn load_from<I, P>(parsers: I) -> Result<Config>where I: IntoIterator<Item = P>, P: Parse + 'static,

Load all data from parsers’ iterator, merge data according to iterator order and return Config.

Errors

If any errors will occur during parsing/merging then error will be returned.

Trait Implementations§

source§

impl Default for ConfigBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.