Enum cfg_rs::ConfigValue[][src]

pub enum ConfigValue<'a> {
    StrRef(&'a str),
    Str(String),
    Int(i64),
    Float(f64),
    Bool(bool),
    Rand(RandValue),
}
Expand description

Config value, ConfigSource use this value to store config properties.

Placeholder expression

Placeholder expression use normalized string representation of crate::ConfigKey, with extra brackets. For example: ${cfg.k1}.

Placeholder expression is powerful in realworld application, it has following benifits:

Placeholder can reduce duplicated configs, use one key config to affect multiple keys.

  • app.name = cfg
  • app.version = 1.0.0
  • app.desc = Application ${app.name}, version ${app.version}

Placeholder can generate configs, we can use placeholder to generate random values.

  • app.id = ${random.u64}
  • app.instance = ${app.name}-${app.id}

Variants

StrRef

String reference, supports placeholder expression.

Tuple Fields of StrRef

0: &'a str
Str

String, supports placeholder expression.

Tuple Fields of Str

0: String
Int

Integer.

Tuple Fields of Int

0: i64
Float

Float value.

Tuple Fields of Float

0: f64
Bool

Bool value.

Tuple Fields of Bool

0: bool
Rand

Random value.

Tuple Fields of Rand

0: RandValue

Trait Implementations

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.