Struct zng_ext_config::settings::SettingBuilder
source · pub struct SettingBuilder<'a> { /* private fields */ }
Expand description
Setting entry builder.
Implementations§
source§impl<'a> SettingBuilder<'a>
impl<'a> SettingBuilder<'a>
sourcepub fn category(&self) -> &CategoryId
pub fn category(&self) -> &CategoryId
Settings category.
sourcepub fn order(&mut self, order: u16) -> &mut Self
pub fn order(&mut self, order: u16) -> &mut Self
Set the setting order number.
Lower numbers are listed first, two categories with the same order are sorted by display name.
sourcepub fn description(&mut self, description: impl IntoVar<Txt>) -> &mut Self
pub fn description(&mut self, description: impl IntoVar<Txt>) -> &mut Self
Set the setting short help text.
sourcepub fn set<T: StateValue>(
&mut self,
id: impl Into<StateId<T>>,
value: impl Into<T>,
) -> &mut Self
pub fn set<T: StateValue>( &mut self, id: impl Into<StateId<T>>, value: impl Into<T>, ) -> &mut Self
Set the custom metadata value.
sourcepub fn meta(&mut self) -> StateMapMut<'_, Setting>
pub fn meta(&mut self) -> StateMapMut<'_, Setting>
Custom setting metadata.
sourcepub fn value<T: ConfigValue>(&mut self, default: T) -> &mut Self
pub fn value<T: ConfigValue>(&mut self, default: T) -> &mut Self
Set the value variable from CONFIG
.
sourcepub fn cfg_value<T: ConfigValue>(
&mut self,
cfg: &mut impl Config,
default: T,
) -> &mut Self
pub fn cfg_value<T: ConfigValue>( &mut self, cfg: &mut impl Config, default: T, ) -> &mut Self
Set the value variable from a different config.
sourcepub fn reset(
&mut self,
resetter: Box<dyn FallbackConfigReset>,
strip_key_prefix: impl Into<Txt>,
) -> &mut Self
pub fn reset( &mut self, resetter: Box<dyn FallbackConfigReset>, strip_key_prefix: impl Into<Txt>, ) -> &mut Self
Use a FallbackConfigReset
to reset the settings.
This is the preferred way of implementing reset as it keeps the user config file clean, but it does require a config setup with two files.
The strip_key_prefix
is removed from config keys before passing to resetter
, this is
required if the config is setup using a switch over multiple files.
sourcepub fn default<T: ConfigValue>(&mut self, default: T) -> &mut Self
pub fn default<T: ConfigValue>(&mut self, default: T) -> &mut Self
Use a default
value to reset the settings.
The default value is set on the config to reset.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SettingBuilder<'a>
impl<'a> !RefUnwindSafe for SettingBuilder<'a>
impl<'a> Send for SettingBuilder<'a>
impl<'a> Sync for SettingBuilder<'a>
impl<'a> Unpin for SettingBuilder<'a>
impl<'a> !UnwindSafe for SettingBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more