pub struct Prompt { /* private fields */ }Expand description
Prompt the user for a string.
§Example
use rusty_rich::Prompt;
let name = Prompt::ask_with("Enter name").unwrap();Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn case_sensitive(self, yes: bool) -> Self
pub fn case_sensitive(self, yes: bool) -> Self
Builder: set case sensitivity.
Sourcepub fn show_choices(self, yes: bool) -> Self
pub fn show_choices(self, yes: bool) -> Self
Builder: show or hide choices.
Sourcepub fn show_default(self, yes: bool) -> Self
pub fn show_default(self, yes: bool) -> Self
Builder: show or hide default.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render the prompt string with styling applied.
Returns a styled string like "Enter name: " where the prompt text and
choices are colored using the theme’s prompt and prompt.choices
styles.
Sourcepub fn ask(&self) -> Result<String, PromptError>
pub fn ask(&self) -> Result<String, PromptError>
Ask the user for string input.
Displays the prompt, reads a line from stdin, validates it against any configured choices, and returns the trimmed string.
§Errors
Returns PromptError::Cancelled on EOF or Ctrl+C,
PromptError::InvalidResponse when the input does not match choices,
and PromptError::IOError on I/O failures.
Auto Trait Implementations§
impl Freeze for Prompt
impl !RefUnwindSafe for Prompt
impl Send for Prompt
impl !Sync for Prompt
impl Unpin for Prompt
impl UnsafeUnpin for Prompt
impl !UnwindSafe for Prompt
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