pub struct InputBuilderOnce<T: FromStr> { /* private fields */ }Expand description
‘builder’ used to store the settings that are used to fetch input.
.get() method takes ownership of the settings so can be called only once without cloning.
This type has support for default input value.
Implementations§
Trait Implementations§
Source§impl<T> Clone for InputBuilderOnce<T>
impl<T> Clone for InputBuilderOnce<T>
Source§impl<T: FromStr> InputBuild<T> for InputBuilderOnce<T>
impl<T: FromStr> InputBuild<T> for InputBuilderOnce<T>
Source§fn msg(self, msg: impl ToString) -> Self
fn msg(self, msg: impl ToString) -> Self
Changes or adds a prompt message that gets printed once when input if fetched. Read more
Source§fn repeat_msg(self, msg: impl ToString) -> Self
fn repeat_msg(self, msg: impl ToString) -> Self
Changes or adds a prompt message and that is repeated each time input is requested. Read more
Source§fn add_test<F: Fn(&T) -> bool + 'static>(self, test: F) -> Self
fn add_test<F: Fn(&T) -> bool + 'static>(self, test: F) -> Self
Adds a validation check on input to ensure the value meets your criteria. Read more
Source§fn add_err_test<F>(self, test: F, err: impl ToString) -> Self
fn add_err_test<F>(self, test: F, err: impl ToString) -> Self
Does the same thing as InputBuild::err, but with a custom error message printed when the test
fails. Read more
Source§fn clear_tests(self) -> Self
fn clear_tests(self) -> Self
Removes all validation checks made by
InputBuild::add_test, InputBuild::add_err_test,
InputBuild::inside and InputBuild::inside_err.Source§fn inside<U: InsideFunc<T>>(self, constraint: U) -> Self
fn inside<U: InsideFunc<T>>(self, constraint: U) -> Self
Ensures that input is within a range, array or vector. Read more
Source§fn inside_err<U: InsideFunc<T>>(self, constraint: U, err: impl ToString) -> Self
fn inside_err<U: InsideFunc<T>>(self, constraint: U, err: impl ToString) -> Self
Does the same thing as
InputBuild::inside, but with a custom error message
printed when input fails.Source§fn toggle_msg_repeat(self) -> Self
fn toggle_msg_repeat(self) -> Self
Toggles whether a prompt message gets printed once or each time input is requested.
Source§fn prompting_on(self, prompt_output: RefCell<Box<dyn Write>>) -> Self
fn prompting_on(self, prompt_output: RefCell<Box<dyn Write>>) -> Self
Send prompts to custom writer instead of stdout
Source§fn prompting_on_stderr(self) -> Self
fn prompting_on_stderr(self) -> Self
Send prompts to stderr instead of stdout
Source§impl<T: FromStr + PartialOrd + 'static> InputConstraints<T> for InputBuilderOnce<T>
impl<T: FromStr + PartialOrd + 'static> InputConstraints<T> for InputBuilderOnce<T>
Source§fn min_err(self, min: T, err: impl ToString) -> Self
fn min_err(self, min: T, err: impl ToString) -> Self
Sets a minimum input value with custom error message.
Source§fn max_err(self, max: T, err: impl ToString) -> Self
fn max_err(self, max: T, err: impl ToString) -> Self
Sets a maximum input value with custom error message.
Source§fn min_max_err(self, min: T, max: T, err: impl ToString) -> Self
fn min_max_err(self, min: T, max: T, err: impl ToString) -> Self
Sets a minimum and maximum input value with custom error message.
Auto Trait Implementations§
impl<T> !Freeze for InputBuilderOnce<T>
impl<T> !RefUnwindSafe for InputBuilderOnce<T>
impl<T> !Send for InputBuilderOnce<T>
impl<T> !Sync for InputBuilderOnce<T>
impl<T> Unpin for InputBuilderOnce<T>where
T: Unpin,
impl<T> !UnwindSafe for InputBuilderOnce<T>
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