pub struct SettingBuilder<'a> { /* private fields */ }
Expand description
Setting entry builder.
Implementations§
source§impl SettingBuilder<'_>
impl SettingBuilder<'_>
sourcepub fn category(&self) -> &CategoryId
pub fn category(&self) -> &CategoryId
Settings category.
sourcepub fn order(&mut self, order: u16) -> &mut SettingBuilder<'_>
pub fn order(&mut self, order: u16) -> &mut SettingBuilder<'_>
Set the setting order number.
Lower numbers are listed first, two categories with the same order are sorted by display name.
sourcepub fn name(&mut self, name: impl IntoVar<Txt>) -> &mut SettingBuilder<'_>
pub fn name(&mut self, name: impl IntoVar<Txt>) -> &mut SettingBuilder<'_>
Set the setting name.
sourcepub fn description(
&mut self,
description: impl IntoVar<Txt>,
) -> &mut SettingBuilder<'_>
pub fn description( &mut self, description: impl IntoVar<Txt>, ) -> &mut SettingBuilder<'_>
Set the setting short help text.
sourcepub fn set<T>(
&mut self,
id: impl Into<StateId<T>>,
value: impl Into<T>,
) -> &mut SettingBuilder<'_>where
T: StateValue,
pub fn set<T>(
&mut self,
id: impl Into<StateId<T>>,
value: impl Into<T>,
) -> &mut SettingBuilder<'_>where
T: StateValue,
Set the custom metadata value.
sourcepub fn flag(&mut self, id: impl Into<StateId<()>>) -> &mut SettingBuilder<'_>
pub fn flag(&mut self, id: impl Into<StateId<()>>) -> &mut SettingBuilder<'_>
Set the custom metadata flag.
sourcepub fn meta(&mut self) -> StateMapMut<'_, Setting>
pub fn meta(&mut self) -> StateMapMut<'_, Setting>
Custom setting metadata.
sourcepub fn value<T>(&mut self, default: T) -> &mut SettingBuilder<'_>where
T: ConfigValue,
pub fn value<T>(&mut self, default: T) -> &mut SettingBuilder<'_>where
T: ConfigValue,
Set the value variable from CONFIG
.
sourcepub fn cfg_value<T>(
&mut self,
cfg: &mut impl Config,
default: T,
) -> &mut SettingBuilder<'_>where
T: ConfigValue,
pub fn cfg_value<T>(
&mut self,
cfg: &mut impl Config,
default: T,
) -> &mut SettingBuilder<'_>where
T: ConfigValue,
Set the value variable from a different config.
sourcepub fn reset(
&mut self,
resetter: Box<dyn FallbackConfigReset>,
strip_key_prefix: impl Into<Txt>,
) -> &mut SettingBuilder<'_>
pub fn reset( &mut self, resetter: Box<dyn FallbackConfigReset>, strip_key_prefix: impl Into<Txt>, ) -> &mut SettingBuilder<'_>
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>(&mut self, default: T) -> &mut SettingBuilder<'_>where
T: ConfigValue,
pub fn default<T>(&mut self, default: T) -> &mut SettingBuilder<'_>where
T: ConfigValue,
Use a default
value to reset the settings.
The default value is set on the config to reset.
Trait Implementations§
source§impl Drop for SettingBuilder<'_>
impl Drop for SettingBuilder<'_>
source§impl SettingBuilderEditorExt for SettingBuilder<'_>
impl SettingBuilderEditorExt for SettingBuilder<'_>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for 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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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