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: usizeHow many leading DFS-leaf steps are wizard-managed.
When current >= input_count, the wizard is complete.
current: usizeDFS-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: StringText buffer for the currently active Leaf/Optional input step.
cursor: usizeByte-cursor within buffer.
array_states: HashMap<usize, ArrayState>State for each Array step, keyed by its DFS-leaf index.
Which button is highlighted when the current step is a Buttons step.
Implementations§
Source§impl WizardState
impl WizardState
Sourcepub fn new(steps: &'static [WizardStep], input_count: usize) -> Self
pub fn new(steps: &'static [WizardStep], input_count: usize) -> Self
Create a fresh wizard. input_count ≤ total leaf count.
Sourcepub fn completed(
steps: &'static [WizardStep],
input_count: usize,
values: Vec<String>,
start_current: usize,
) -> Self
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).
Sourcepub fn preload_array(&mut self, step_idx: usize, items: Vec<Vec<String>>)
pub fn preload_array(&mut self, step_idx: usize, items: Vec<Vec<String>>)
Pre-populate an Array step with existing items (edit mode).
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
True when all input_count steps have been confirmed.
Sourcepub fn set_current(&mut self, leaf_idx: usize)
pub fn set_current(&mut self, leaf_idx: usize)
Set the active leaf index directly (for externally-managed steps).
Sourcepub fn array_state(&self, leaf_idx: usize) -> Option<&ArrayState>
pub fn array_state(&self, leaf_idx: usize) -> Option<&ArrayState>
Borrow the state of an Array step by DFS-leaf index.
Sourcepub fn array_state_mut(&mut self, leaf_idx: usize) -> Option<&mut ArrayState>
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.
Sourcepub fn array_selected_item(&self, leaf_idx: usize) -> Option<usize>
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).
Sourcepub fn is_array_editing(&self) -> bool
pub fn is_array_editing(&self) -> bool
True when the current step is an Array with an active editing session.
Sourcepub fn handle_key(&mut self, key: KeyEvent) -> WizardEvent
pub fn handle_key(&mut self, key: KeyEvent) -> WizardEvent
Handle a key event. Only meaningful when !is_complete().
Auto Trait Implementations§
impl Freeze for WizardState
impl RefUnwindSafe for WizardState
impl Send for WizardState
impl Sync for WizardState
impl Unpin for WizardState
impl UnsafeUnpin for WizardState
impl UnwindSafe for WizardState
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
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