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(&'a str)

String reference, supports placeholder expression.

Str(String)

String, supports placeholder expression.

Int(i64)

Integer.

Float(f64)

Float value.

Bool(bool)

Bool value.

Rand(RandValue)

Random value.

Trait Implementations

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

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

Returns the argument unchanged.

Calls U::from(self).

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

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.