Skip to main content

ActiveConfiguration

Struct ActiveConfiguration 

Source
pub struct ActiveConfiguration {
    pub chip: Chip,
    pub selected: Vec<usize>,
    pub options: Vec<GeneratorOptionItem>,
    pub flat_options: Vec<GeneratorOption>,
}

Fields§

§chip: Chip

The chip that is configured for

§selected: Vec<usize>

The names of the selected options

§options: Vec<GeneratorOptionItem>

The tree of all available options

§flat_options: Vec<GeneratorOption>

All available option items (categories are not included), flattened to avoid the need for recursion.

Implementations§

Source§

impl ActiveConfiguration

Source

pub fn is_group_selected(&self, group: &str) -> bool

Source

pub fn is_selected(&self, option: &str) -> bool

Source

pub fn selected_index(&self, option: &str) -> Option<usize>

Source

pub fn select(&mut self, option: &str)

Source

pub fn select_idx(&mut self, idx: usize)

Selects the option at idx.

Negative requirements (!X) on this option force-deselect X if it’s currently selected. The deselection cascades: anything whose requirements are no longer met is dropped as well (there is no save/restore mechanism; swapped-out options simply disappear until the user re-enables them).

Positive requirements remain hard gates — if any of them is unmet the call is a no-op.

Source

pub fn deselect_idx(&mut self, idx: usize)

Deselects the option at idx, then cascades: any remaining selection whose requirements were propped up by the one we just removed is dropped too. This is the counterpart to Self::select_idx’s cascade, and gives the user a predictable “clear, don’t save” experience when toggling off an option that others depend on (e.g. toggling probe-rs off clears panic-rtt-target).

Source

pub fn would_force_deselect(&self, option: &GeneratorOption) -> Vec<String>

Returns the names of currently-selected options that would be force-deselected (directly or via cascade) if the user toggled the given option. Empty when toggling would be non-destructive.

Symmetric: works whether the option is currently selected (simulates deselect, reports cascade) or not (simulates select, reports same-group siblings, negative-requirement targets, and cascade). The option being toggled is never itself reported — only collateral damage.

Defensive short-circuit: if the option is currently unselected and cannot actually be toggled on (chip-mismatch or an unmet positive requirement), the toggle would be a no-op, so we return an empty list. We gate on Self::is_option_toggleable rather than the strict Self::is_option_active on purpose — a row whose only conflict is a negative requirement is toggleable (selecting it cascades the conflict out), and its cascade is exactly what callers want reported.

Source

pub fn is_active(&self, item: &GeneratorOptionItem) -> bool

Returns whether an item is toggleable in the UI.

For a category, the category’s own requirements must be met (strict) and at least one descendant must itself be toggleable; for a leaf option this uses Self::is_option_toggleable, i.e. an option with an unmet !X is still considered reachable because selecting it would cascade X out.

This is the TUI-facing predicate. For strict validation (e.g. the CLI checking whether a user’s selection set is self-consistent), use Self::is_option_active directly.

Source

pub fn is_option_active(&self, option: &GeneratorOption) -> bool

Strict “is this option consistent with the current selection?” predicate.

Returns true only when:

  • the option is available for the current chip,
  • every one of its requirements is satisfied (including negative ones), and
  • no other currently-selected option has !{option.name} in its requires.

This is the right check for validation: the CLI (esp-generate --headless -o …) and the xtask regression harness rely on it to reject inconsistent selection sets. It is not the right check for “can the user click this row in the TUI” — that’s Self::is_option_toggleable, which permits negative-requirement conflicts on the understanding that selecting the row will cascade them out via Self::select_idx.

Source

pub fn is_option_toggleable(&self, option: &GeneratorOption) -> bool

Permissive “can the user toggle this row in the TUI?” predicate.

Returns true when the option is available for the current chip and every positive requirement is met. Negative requirements (!X) are intentionally ignored here: the TUI treats them as force-deselect hints, not gates. Selecting a row in this state routes through Self::select_idx, which cascades the negative-requirement targets (and their dependents) out; use Self::would_force_deselect to preview that cascade.

Callers that care about full self-consistency (CLI validation, xtask coverage) must use Self::is_option_active instead.

Source

pub fn can_be_disabled(&self, option: &str) -> bool

Source

pub fn collect_relationships<'a>( &'a self, option: &'a GeneratorOptionItem, ) -> Relationships<'a>

Trait Implementations§

Source§

impl Debug for ActiveConfiguration

Source§

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

Formats the value using the given formatter. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.