Skip to main content

Prompter

Trait Prompter 

Source
pub trait Prompter: Send + Sync {
    // Required methods
    fn select(
        &self,
        prompt: &str,
        options: &[String],
    ) -> Result<usize, ManageError>;
    fn confirm(&self, prompt: &str) -> Result<bool, ManageError>;
}
Expand description

Interactive UI surface used by doctor and branch.

Production binaries inject DialoguerPrompter; tests inject ScriptedPrompter (gated on test-util) so prompt-driven flows can be exercised deterministically without spawning the binary.

Required Methods§

Source

fn select(&self, prompt: &str, options: &[String]) -> Result<usize, ManageError>

Ask the user to pick one of options by index. prompt is the short headline shown above the choices.

§Errors

Returns ManageError::Cancelled if the user aborts (Ctrl+C or EOF), or ManageError::Io for underlying I/O failures.

Source

fn confirm(&self, prompt: &str) -> Result<bool, ManageError>

Ask the user a yes/no question. Returns Ok(true) for “yes” and Ok(false) for “no”.

§Errors

Returns ManageError::Cancelled on EOF or signal, or ManageError::Io for underlying I/O failures.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§