pub struct Input(/* private fields */);
Expand description
A prompt that asks the user to enter text input
Implementations§
Source§impl Input
impl Input
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 Input
impl Input
Sourcepub fn set_default(&mut self, value: String)
pub fn set_default(&mut self, value: String)
Set the default selection. If the user does not input anything, this value will be used instead.
Sourcepub fn with_default<I: Into<String>>(&mut self, value: I) -> &mut Self
pub fn with_default<I: Into<String>>(&mut self, value: I) -> &mut Self
Builder pattern for Self::set_default
Source§impl Input
impl Input
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
Source§impl Input
impl Input
pub fn set_inital_text<S: ToString>(&mut self, text: S)
pub fn with_initial_text<S: ToString>(&mut self, text: S) -> &mut Self
Auto Trait Implementations§
impl Freeze for Input
impl !RefUnwindSafe for Input
impl !Send for Input
impl !Sync for Input
impl Unpin for Input
impl !UnwindSafe for Input
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