[−][src]Struct prompts::text::TextPrompt
Interactive prompt that accepts text input
Examples
use prompt::{text::TextPrompt, Prompt}; let mut prompt = TextPrompt::new("What is your name?"); match prompt.run().await { Ok(Some(s)) => println!("You wrote: {}", s), Ok(None) => println!("Prompt was aborted!"), Err(e) => println!("Some kind of crossterm error happened: {:?}", e), }
Methods
impl TextPrompt
[src]
pub fn new<S>(message: S) -> TextPrompt where
S: Into<String>,
[src]
S: Into<String>,
Returns a TextPrompt ready to be run
Arguments
message
- The message to display to the user before the prompt
pub fn with_style(self, style: Style) -> TextPrompt
[src]
Mask typed letters with a given style (currently only invisible or password)
Arguments
style
- The style to use
pub fn with_validator(
self,
validator: fn(input: &str) -> Result<(), String>
) -> TextPrompt
[src]
self,
validator: fn(input: &str) -> Result<(), String>
) -> TextPrompt
Provide a custom validation closure
Arguments
validator
- Validation closure that accepts a string, and returns Ok if valid, or a string error to show if invalid.
Trait Implementations
impl Debug for TextPrompt
[src]
impl Default for TextPrompt
[src]
fn default() -> TextPrompt
[src]
impl Prompt<String> for TextPrompt
[src]
Auto Trait Implementations
impl RefUnwindSafe for TextPrompt
impl Send for TextPrompt
impl Sync for TextPrompt
impl Unpin for TextPrompt
impl UnwindSafe for TextPrompt
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,