Struct read_input::InputBuilder
source · pub struct InputBuilder<T: FromStr> { /* private fields */ }
Expand description
‘builder’ used to store the settings that are used to fetch input.
.get()
method only takes these settings by reference so can be called multiple times.
This type does not have support for default input value.
Implementations
sourceimpl<T: FromStr> InputBuilder<T>
impl<T: FromStr> InputBuilder<T>
Trait Implementations
sourceimpl<T: FromStr + Clone> Clone for InputBuilder<T>
impl<T: FromStr + Clone> Clone for InputBuilder<T>
sourceimpl<T: FromStr> Default for InputBuilder<T>
impl<T: FromStr> Default for InputBuilder<T>
sourceimpl<T: FromStr> InputBuild<T> for InputBuilder<T>
impl<T: FromStr> InputBuild<T> for InputBuilder<T>
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn add_err_test<F>(self, test: F, err: impl ToString) -> Selfwhere
F: Fn(&T) -> bool + 'static,
fn add_err_test<F>(self, test: F, err: impl ToString) -> Selfwhere
F: Fn(&T) -> bool + 'static,
Adds a validation check on input with a custom error message printed when the test
fails. Read more
sourcefn clear_tests(self) -> Self
fn clear_tests(self) -> Self
Removes all validation checks made by
.add_test()
, .add_err_test()
,
.inside()
and .inside_err()
. Read moresourcefn err_match<F>(self, err_match: F) -> Selfwhere
F: Fn(&T::Err) -> Option<String> + 'static,
fn err_match<F>(self, err_match: F) -> Selfwhere
F: Fn(&T::Err) -> Option<String> + 'static,
Used specify custom error messages that depend on the errors produced by
from_str()
.sourcefn 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.
sourcefn 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
Ensures that input is within a range, array or vector with a custom error message
printed when input fails. Read more
sourcefn 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.
sourceimpl<T> InputConstraints<T> for InputBuilder<T>where
T: FromStr,
T: PartialOrd,
T: 'static,
impl<T> InputConstraints<T> for InputBuilder<T>where
T: FromStr,
T: PartialOrd,
T: 'static,
sourcefn 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.
sourcefn 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.
sourcefn 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> !RefUnwindSafe for InputBuilder<T>
impl<T> !Send for InputBuilder<T>
impl<T> !Sync for InputBuilder<T>
impl<T> Unpin for InputBuilder<T>
impl<T> !UnwindSafe for InputBuilder<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more