[][src]Trait read_input::InputBuild

pub trait InputBuild<T: FromStr> {
    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; }

Trait for comman types that store input settings.

Required methods

fn msg(self, msg: impl ToString) -> Self

Changes or adds a prompt message that gets printed once when input if fetched.

fn repeat_msg(self, msg: impl ToString) -> Self

Changes or adds a prompt message and that is repeated each time input is requested.

fn err(self, err: impl ToString) -> Self

Changes fallback error message.

fn add_test<F: Fn(&T) -> bool + 'static>(self, test: F) -> Self

Adds a validation check on input.

fn add_err_test<F>(self, test: F, err: impl ToString) -> Self where
    F: Fn(&T) -> bool + 'static, 

Adds a validation check on input with a custom error message printed when the test fails.

fn clear_tests(self) -> Self

Removes all validation checks made by .add_test(), .add_err_test(), .inside() and .inside_err().

fn err_match<F>(self, err_match: F) -> Self where
    F: Fn(&T::Err) -> Option<String> + 'static, 

Used specify custom error messages that depend on the errors produced by from_str().

fn inside<U: InsideFunc<T>>(self, constraint: U) -> Self

Ensures that input is within a range, array or vector.

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.

fn toggle_msg_repeat(self) -> Self

Toggles whether a prompt message gets printed once or each time input is requested.

Loading content...

Implementors

impl<T: FromStr> InputBuild<T> for InputBuilder<T>[src]

impl<T: FromStr> InputBuild<T> for InputBuilderOnce<T>[src]

Loading content...