Skip to main content

WizardState

Struct WizardState 

Source
pub struct WizardState {
    pub steps: &'static [WizardStep],
    pub input_count: usize,
    pub current: usize,
    pub values: Vec<String>,
    pub buffer: String,
    pub cursor: usize,
    pub array_states: HashMap<usize, ArrayState>,
    pub button_selected: usize,
}
Expand description

All mutable wizard state.

Fields§

§steps: &'static [WizardStep]

The full step tree (static, defined by the caller).

§input_count: usize

How many leading DFS-leaf steps are wizard-managed. When current >= input_count, the wizard is complete.

§current: usize

DFS-leaf index of the currently active step.

§values: Vec<String>

Confirmed string values for non-array leaf steps. Indexed by step leaf index; may be sparse if the user cycled backward.

§buffer: String

Text buffer for the currently active Leaf/Optional input step.

§cursor: usize

Byte-cursor within buffer.

§array_states: HashMap<usize, ArrayState>

State for each Array step, keyed by its DFS-leaf index.

§button_selected: usize

Which button is highlighted when the current step is a Buttons step.

Implementations§

Source§

impl WizardState

Source

pub fn new(steps: &'static [WizardStep], input_count: usize) -> Self

Create a fresh wizard. input_count ≤ total leaf count.

Source

pub fn completed( steps: &'static [WizardStep], input_count: usize, values: Vec<String>, start_current: usize, ) -> Self

Build a pre-completed wizard (edit mode — values already known).

Source

pub fn preload_array(&mut self, step_idx: usize, items: Vec<Vec<String>>)

Pre-populate an Array step with existing items (edit mode).

Source

pub fn is_complete(&self) -> bool

True when all input_count steps have been confirmed.

Source

pub fn set_current(&mut self, leaf_idx: usize)

Set the active leaf index directly (for externally-managed steps).

Source

pub fn array_state(&self, leaf_idx: usize) -> Option<&ArrayState>

Borrow the state of an Array step by DFS-leaf index.

Source

pub fn array_state_mut(&mut self, leaf_idx: usize) -> Option<&mut ArrayState>

Mutably borrow the state of an Array step by DFS-leaf index.

Source

pub fn array_selected_item(&self, leaf_idx: usize) -> Option<usize>

Return the currently highlighted item index (0-based) for an Array step, or None if no item is focused (e.g. array is collapsed).

Source

pub fn is_array_editing(&self) -> bool

True when the current step is an Array with an active editing session.

Source

pub fn handle_key(&mut self, key: KeyEvent) -> WizardEvent

Handle a key event. Only meaningful when !is_complete().

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.