Enum ConfigValue

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

Source§

impl<'a> Debug for ConfigValue<'a>

Source§

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

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

impl<'a> From<&'a str> for ConfigValue<'a>

Source§

fn from(c: &'a str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ConfigValue<'_>

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for ConfigValue<'_>

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for ConfigValue<'_>

Source§

fn from(c: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for ConfigValue<'_>

Source§

fn from(c: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for ConfigValue<'_>

Source§

fn from(c: i128) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for ConfigValue<'_>

Source§

fn from(c: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for ConfigValue<'_>

Source§

fn from(c: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for ConfigValue<'_>

Source§

fn from(c: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for ConfigValue<'_>

Source§

fn from(c: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for ConfigValue<'_>

Source§

fn from(c: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for ConfigValue<'_>

Source§

fn from(c: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for ConfigValue<'_>

Source§

fn from(c: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for ConfigValue<'_>

Source§

fn from(c: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for ConfigValue<'_>

Source§

fn from(c: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for ConfigValue<'_>

Source§

fn from(c: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for ConfigValue<'_>

Source§

fn from(c: usize) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for ConfigValue<'a>

§

impl<'a> RefUnwindSafe for ConfigValue<'a>

§

impl<'a> Send for ConfigValue<'a>

§

impl<'a> Sync for ConfigValue<'a>

§

impl<'a> Unpin for ConfigValue<'a>

§

impl<'a> UnwindSafe for ConfigValue<'a>

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V