pub struct Password(/* private fields */);
Expand description
A prompt that asks the user to enter a password
Implementations§
Source§impl Password
impl Password
Sourcepub fn new() -> Result<Self, InteractionError>
pub fn new() -> Result<Self, InteractionError>
Create the prompt, returning an error if interactive context is incorrectly set.
Sourcepub fn set_prompt(&mut self, prompt: String)
pub fn set_prompt(&mut self, prompt: String)
Set the prompt.
Sourcepub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self
pub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self
Builder pattern for Self::set_prompt
Sourcepub fn interact(&mut self) -> Result<String, InteractionError>
pub fn interact(&mut self) -> Result<String, InteractionError>
Present the prompt to the user. May return an error if in a non-interactive context, or interaction fails for any other reason
Source§impl Password
impl Password
Sourcepub fn set_confirmation<S: ToString>(
&mut self,
confirm_prompt: S,
mismatch_err: S,
)
pub fn set_confirmation<S: ToString>( &mut self, confirm_prompt: S, mismatch_err: S, )
Ask the user to confirm the password with the provided prompt & error message.
Sourcepub fn with_confirmation<S: ToString>(
&mut self,
confirm_prompt: S,
mismatch_err: S,
) -> &mut Self
pub fn with_confirmation<S: ToString>( &mut self, confirm_prompt: S, mismatch_err: S, ) -> &mut Self
Builder pattern for Self::set_confirmation
Source§impl Password
impl Password
Sourcepub fn set_allow_empty(&mut self, empty: bool)
pub fn set_allow_empty(&mut self, empty: bool)
Sets if no input is a valid input. Default: false
.
Sourcepub fn with_allow_empty(&mut self, empty: bool) -> &mut Self
pub fn with_allow_empty(&mut self, empty: bool) -> &mut Self
Builder pattern for Self::set_allow_empty
Sourcepub fn set_validator<V, E>(&mut self, validator: V)
pub fn set_validator<V, E>(&mut self, validator: V)
Sourcepub fn with_validator<V, E>(&mut self, validator: V) -> &mut Self
pub fn with_validator<V, E>(&mut self, validator: V) -> &mut Self
Builder pattern for Self::set_validator
Auto Trait Implementations§
impl Freeze for Password
impl !RefUnwindSafe for Password
impl !Send for Password
impl !Sync for Password
impl Unpin for Password
impl !UnwindSafe for Password
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
Mutably borrows from an owned value. Read more