Skip to main content

InputProvider

Trait InputProvider 

Source
pub trait InputProvider: Send + Sync {
    // Required methods
    fn password(&self, prompt: &str) -> Result<String>;
    fn password_with_confirm(&self, prompt: &str) -> Result<String>;
    fn confirm(&self, prompt: &str, default: bool) -> Result<bool>;
    fn input_text(&self, prompt: &str, default: Option<&str>) -> Result<String>;
    fn select(
        &self,
        prompt: &str,
        items: &[String],
        default: usize,
    ) -> Result<usize>;
}
Expand description

Abstract input provider for user interaction.

Required Methods§

Source

fn password(&self, prompt: &str) -> Result<String>

Read a password (no echo).

Source

fn password_with_confirm(&self, prompt: &str) -> Result<String>

Read a password with confirmation (no echo, entered twice).

Source

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

Ask a yes/no question.

Source

fn input_text(&self, prompt: &str, default: Option<&str>) -> Result<String>

Read a text input with optional default.

Source

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

Select from a list of items.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§