Struct read_input::InputBuilder
source · pub struct InputBuilder<'a, T>where
T: FromStr,{ /* private fields */ }
Expand description
InputBuilder
is a ‘builder’ used to store the settings that are used to fetch input.
Implementations§
source§impl<'a, T> InputBuilder<'a, T>where
T: FromStr,
impl<'a, T> InputBuilder<'a, T>where
T: FromStr,
sourcepub fn new() -> InputBuilder<'a, T>
pub fn new() -> InputBuilder<'a, T>
Creates a new instance of InputBuilder
with default settings.
sourcepub fn msg(self, msg: &'a str) -> Self
pub fn msg(self, msg: &'a str) -> Self
Changes or adds a prompt message. This is documented in the readme
sourcepub fn repeat_msg(self, msg: &'a str) -> Self
pub fn repeat_msg(self, msg: &'a str) -> Self
Changes or adds a prompt message and makes it repeat. This is documented in the readme
sourcepub fn err(self, err: &'a str) -> Self
pub fn err(self, err: &'a str) -> Self
Changes fallback error message. This is documented in the readme
sourcepub fn default(self, default: T) -> Self
pub fn default(self, default: T) -> Self
Changes or adds a default input value. This is documented in the readme
sourcepub fn add_test<F: 'static + Fn(&T) -> bool>(self, test: F) -> Self
pub fn add_test<F: 'static + Fn(&T) -> bool>(self, test: F) -> Self
Adds a validation check on input. This is documented in the readme
sourcepub fn add_err_test<F: 'static + Fn(&T) -> bool>(
self,
test: F,
err: &'a str
) -> Self
pub fn add_err_test<F: 'static + Fn(&T) -> bool>(
self,
test: F,
err: &'a str
) -> Self
Adds a validation check on input with custom error message. This is documented in the readme
sourcepub fn clear_tests(self) -> Self
pub fn clear_tests(self) -> Self
Removes all validation checks made by .add_test()
and .add_err_test()
.