Struct inquire::Password [−][src]
pub struct Password<'a> { pub message: &'a str, pub help_message: Option<&'a str>, pub formatter: StringFormatter<'a>, pub validators: Vec<StringValidator<'a>>, }
Expand description
Prompt meant for secretive text inputs.
It is a simple text prompt where the user’s input is captured and not echoed back to the terminal.
This prompt is meant to be as simple and raw as possible, not supporting features such as default values or auto-completion.
By default, the user submission is formatted as “********” (eight star characters).
This prompt still allows the caller to customize standard properties: validators, input formatter, error and help messages.
Example
use inquire::Password; let name = Password::new("Encryption key:").prompt(); match name { Ok(_) => println!("This doesn't look like a key."), Err(_) => println!("An error happened when asking for your key, try again later."), }
Fields
message: &'a str
Message to be presented to the user.
help_message: Option<&'a str>
Help message to be presented to the user.
formatter: StringFormatter<'a>
Function that formats the user input and presents it to the user as the final rendering of the prompt.
validators: Vec<StringValidator<'a>>
Collection of validators to apply to the user input.
Validators are executed in the order they are stored, stopping at and displaying to the user only the first validation error that might appear.
The possible error is displayed to the user one line above the prompt.
Implementations
Default formatter, set to always display "********"
regardless of input length.
Default validators added to the Password prompt, none.
Default help message.
Creates a Password with the provided message and default options.
Sets the help message of the prompt.
Sets the formatter.
Adds a validator to the collection of validators. You might want to use this feature in case you need to limit the user to specific choices, such as requiring special characters in the password.
Validators are executed in the order they are stored, stopping at and displaying to the user only the first validation error that might appear.
The possible error is displayed to the user one line above the prompt.
Adds the validators to the collection of validators in the order they are given.
Validators are executed in the order they are stored, stopping at and displaying to the user only the first validation error that might appear.
The possible error is displayed to the user one line above the prompt.
Parses the provided behavioral and rendering options and prompts the CLI user for input according to the defined rules.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Password<'a>
impl<'a> !UnwindSafe for Password<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more