pub trait ConfigType: Sized {
    type Default: Into<Self> + Clone;
    type Shared;

    // Required methods
    fn shared<'a>(
        config: &Config<Self>,
        vals: &'a ConfigSet
    ) -> Option<&'a Arc<Self::Shared>>;
    fn to_val(val: &Self) -> ConfigVal;
    fn get(x: &Self::Shared) -> Self;
    fn set(x: &Self::Shared, val: Self);
}
Expand description

A type usable as a Config.

Required Associated Types§

source

type Default: Into<Self> + Clone

A const-compatible type suitable for use as the default value of configs of this type.

source

type Shared

A value of this type, sharable between config value updaters (like LaunchDarkly) and config value retrievers.

Required Methods§

source

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

Extracts the sharable value for a config of this type from a set.

External users likely want Config::shared instead.

source

fn to_val(val: &Self) -> ConfigVal

Converts this type to its type-erased enum equivalent.

source

fn get(x: &Self::Shared) -> Self

Retrieves the current config value of this type from a value of its corresponding sharable type.

External users likely want Config::get or Config::get_from_shared instead.

source

fn set(x: &Self::Shared, val: Self)

Updates the sharable value for a config of this type to the given value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ConfigType for bool

§

type Default = bool

§

type Shared = AtomicBool

source§

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

source§

fn to_val(val: &Self) -> ConfigVal

source§

fn set(x: &Self::Shared, val: Self)

source§

fn get(x: &Self::Shared) -> Self

source§

impl ConfigType for u32

§

type Default = u32

§

type Shared = AtomicU32

source§

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

source§

fn to_val(val: &Self) -> ConfigVal

source§

fn set(x: &Self::Shared, val: Self)

source§

fn get(x: &Self::Shared) -> Self

source§

impl ConfigType for usize

§

type Default = usize

§

type Shared = AtomicU64

source§

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

source§

fn to_val(val: &Self) -> ConfigVal

source§

fn set(x: &Self::Shared, val: Self)

source§

fn get(x: &Self::Shared) -> Self

source§

impl ConfigType for String

§

type Default = &'static str

§

type Shared = RwLock<String>

source§

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

source§

fn to_val(val: &Self) -> ConfigVal

source§

fn set(x: &Self::Shared, val: Self)

source§

fn get(x: &Self::Shared) -> Self

source§

impl ConfigType for Duration

§

type Default = Duration

§

type Shared = RwLock<Duration>

source§

fn shared<'a>( config: &Config<Self>, vals: &'a ConfigSet ) -> Option<&'a Arc<Self::Shared>>

source§

fn to_val(val: &Self) -> ConfigVal

source§

fn set(x: &Self::Shared, val: Self)

source§

fn get(x: &Self::Shared) -> Self

Implementors§