SettingValue

Enum SettingValue 

Source
pub enum SettingValue {
    Bool(bool),
    Choice {
        options: Vec<String>,
        selected: usize,
    },
    Number {
        value: i32,
        min: i32,
        max: i32,
        step: i32,
    },
    Display(String),
    Action(ActionType),
}
Expand description

Types of setting values

Variants§

§

Bool(bool)

Boolean toggle (checkbox)

§

Choice

Multiple choice (dropdown)

Fields

§options: Vec<String>
§selected: usize
§

Number

Numeric value with bounds

Fields

§value: i32
§min: i32
§max: i32
§step: i32
§

Display(String)

Read-only display value

§

Action(ActionType)

Action button

Implementations§

Source§

impl SettingValue

Source

pub const fn toggle(&mut self)

Toggle a boolean value

Source

pub const fn cycle_next(&mut self)

Cycle to next choice option

Source

pub const fn cycle_prev(&mut self)

Cycle to previous choice option

Source

pub const fn quick_select(&mut self, index: u8)

Quick select a choice by index (1-based)

Source

pub fn increment(&mut self)

Increment a number value

Source

pub fn decrement(&mut self)

Decrement a number value

Source

pub fn display_value(&self) -> String

Get the current value as a display string

Source

pub const fn is_bool(&self) -> bool

Check if this is a toggleable bool

Source

pub const fn is_choice(&self) -> bool

Check if this is a choice/cycle value

Source

pub const fn is_number(&self) -> bool

Check if this is a number value

Source

pub const fn is_action(&self) -> bool

Check if this is an action

Source

pub const fn is_display(&self) -> bool

Check if this is a display-only value

Source

pub const fn choice_count(&self) -> Option<usize>

Get choice options count (for rendering [1/2/3] hints)

Source§

impl SettingValue

Source

pub fn from_option_with_constraint( opt: &OptionValue, constraint: &OptionConstraint, ) -> Self

Create a SettingValue from an OptionValue with constraint information.

Uses the constraint’s min/max for integer bounds.

Source

pub fn item_from_spec(spec: &OptionSpec, value: &OptionValue) -> SettingItem

Create a SettingItem from an OptionSpec with its current value.

Source

pub fn to_option_value(&self) -> Option<OptionValue>

Convert this SettingValue back to an OptionValue.

Note: Display and Action variants cannot be converted and return None.

Trait Implementations§

Source§

impl Clone for SettingValue

Source§

fn clone(&self) -> SettingValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SettingValue

Source§

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

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

impl From<&OptionValue> for SettingValue

Source§

fn from(opt: &OptionValue) -> Self

Convert an OptionValue to a SettingValue without constraint information.

For integers, uses unbounded min/max. Use SettingValue::from_option_with_constraint for proper bounds.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more