pub struct InputHandler { /* private fields */ }
Expand description
Input handler for terminal interface
Implementations§
Source§impl InputHandler
impl InputHandler
Sourcepub fn prompt(&mut self, message: &str) -> Result<String>
pub fn prompt(&mut self, message: &str) -> Result<String>
Prompt user with a message and read input
Sourcepub fn read_number<T>(&mut self, prompt: &str) -> Result<T>
pub fn read_number<T>(&mut self, prompt: &str) -> Result<T>
Read a number from input with validation
Sourcepub fn read_yes_no(&mut self, prompt: &str) -> Result<bool>
pub fn read_yes_no(&mut self, prompt: &str) -> Result<bool>
Read a yes/no answer from input
Sourcepub fn read_validated<F>(
&mut self,
prompt: &str,
validator: F,
) -> Result<String>
pub fn read_validated<F>( &mut self, prompt: &str, validator: F, ) -> Result<String>
Read input with validation using a predicate function
Sourcepub fn read_choice(&mut self, prompt: &str, choices: &[&str]) -> Result<usize>
pub fn read_choice(&mut self, prompt: &str, choices: &[&str]) -> Result<usize>
Read input from a list of choices
Sourcepub fn clear_buffer(&mut self)
pub fn clear_buffer(&mut self)
Clear the input buffer
Trait Implementations§
Source§impl Debug for InputHandler
impl Debug for InputHandler
Source§impl Default for InputHandler
impl Default for InputHandler
Source§fn default() -> InputHandler
fn default() -> InputHandler
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InputHandler
impl RefUnwindSafe for InputHandler
impl Send for InputHandler
impl Sync for InputHandler
impl Unpin for InputHandler
impl UnwindSafe for InputHandler
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more