Struct Password

Source
pub struct Password(/* private fields */);
Expand description

A prompt that asks the user to enter a password

Implementations§

Source§

impl Password

Source

pub fn new() -> Result<Self, InteractionError>

Create the prompt, returning an error if interactive context is incorrectly set.

Source

pub fn set_prompt(&mut self, prompt: String)

Set the prompt.

Source

pub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self

Builder pattern for Self::set_prompt

Source

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

Source

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.

Source

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

Source

pub fn set_allow_empty(&mut self, empty: bool)

Sets if no input is a valid input. Default: false.

Source

pub fn with_allow_empty(&mut self, empty: bool) -> &mut Self

Builder pattern for Self::set_allow_empty

Source

pub fn set_validator<V, E>(&mut self, validator: V)
where V: Fn(&String) -> Result<(), E> + 'static, E: ToString,

Set a validator to be run on input. If the validator returns Ok, the input will be deemed valid. If the validator returns Err, the prompt will display the error message

Source

pub fn with_validator<V, E>(&mut self, validator: V) -> &mut Self
where V: Fn(&String) -> Result<(), E> + 'static, E: ToString,

Builder pattern for Self::set_validator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.