pub trait InputBuild<T: FromStr> {
// Required methods
fn msg(self, msg: impl ToString) -> Self;
fn repeat_msg(self, msg: impl ToString) -> Self;
fn err(self, err: impl ToString) -> Self;
fn add_test<F: Fn(&T) -> bool + 'static>(self, test: F) -> Self;
fn add_err_test<F>(self, test: F, err: impl ToString) -> Self
where F: Fn(&T) -> bool + 'static;
fn clear_tests(self) -> Self;
fn err_match<F>(self, err_match: F) -> Self
where F: Fn(&T::Err) -> Option<String> + 'static;
fn inside<U: InsideFunc<T>>(self, constraint: U) -> Self;
fn inside_err<U: InsideFunc<T>>(
self,
constraint: U,
err: impl ToString,
) -> Self;
fn toggle_msg_repeat(self) -> Self;
fn prompting_on(self, prompt_output: RefCell<Box<dyn Write>>) -> Self;
fn prompting_on_stderr(self) -> Self;
}Expand description
Trait for common types that store input settings.
Required Methods§
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) -> Self
fn add_err_test<F>(self, test: F, err: impl ToString) -> Self
Adds a validation check on input with a custom error message printed when the test fails.
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().
Sourcefn err_match<F>(self, err_match: F) -> Self
fn err_match<F>(self, err_match: F) -> Self
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.
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.
Sourcefn 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
Sourcefn prompting_on_stderr(self) -> Self
fn prompting_on_stderr(self) -> Self
Send prompts to stderr instead of stdout
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.