pub struct Password<'a> { /* private fields */ }
Expand description
Renders a password input prompt.
Example usage
use dialoguer::Password;
let password = Password::new().with_prompt("New Password")
.with_confirmation("Confirm password", "Passwords mismatching")
.interact()?;
println!("Length of the password is: {}", password.len());
Implementations
sourceimpl Password<'_>
impl Password<'_>
sourcepub fn with_prompt<S: Into<String>>(&mut self, prompt: S) -> &mut Self
pub fn with_prompt<S: Into<String>>(&mut self, prompt: S) -> &mut Self
Sets the password input prompt.
sourcepub fn report(&mut self, val: bool) -> &mut Self
pub fn report(&mut self, val: bool) -> &mut Self
Indicates whether to report confirmation after interaction.
The default is to report.
sourcepub fn with_confirmation<A, B>(&mut self, prompt: A, mismatch_err: B) -> &mut Self where
A: Into<String>,
B: Into<String>,
pub fn with_confirmation<A, B>(&mut self, prompt: A, mismatch_err: B) -> &mut Self where
A: Into<String>,
B: Into<String>,
Enables confirmation prompting.
sourcepub fn allow_empty_password(&mut self, allow_empty_password: bool) -> &mut Self
pub fn allow_empty_password(&mut self, allow_empty_password: bool) -> &mut Self
Allows/Disables empty password.
By default this setting is set to false (i.e. password is not empty).
sourcepub fn interact(&self) -> Result<String>
pub fn interact(&self) -> Result<String>
Enables user interaction and returns the result.
If the user confirms the result is true
, false
otherwise.
The dialog is rendered on stderr.
sourcepub fn interact_on(&self, term: &Term) -> Result<String>
pub fn interact_on(&self, term: &Term) -> Result<String>
Like interact
but allows a specific terminal to be set.
sourceimpl<'a> Password<'a>
impl<'a> Password<'a>
sourcepub fn with_theme(theme: &'a dyn Theme) -> Self
pub fn with_theme(theme: &'a dyn Theme) -> Self
Creates a password input prompt with a specific theme.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Password<'a>
impl<'a> !Send for Password<'a>
impl<'a> !Sync for Password<'a>
impl<'a> Unpin for Password<'a>
impl<'a> !UnwindSafe for Password<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more