pub struct FormInputBuilder { /* private fields */ }

Implementations

Form Field: Text output

Form Field: Vertical spacing

Form Field: Prompt for a string value

Form Field: Prompt for multi-line string value

Form Field: Prompt for an integer

Form Field: Prompt for an address

Form Field: Prompt for a choice from provided options

Form Field: Prompt for file to open

Form Field: Prompt for file to save to

Form Field: Prompt for directory name

Prompts the user for a set of inputs specified in fields with given title. The fields parameter is a list which can contain the following types:

This API is flexible and works both in the UI via a pop-up dialog and on the command-line.

let responses = interaction::FormInputBuilder::new()
    .text_field("First Name", None)
    .text_field("Last Name", None)
    .choice_field(
        "Favorite Food",
        &vec![
            "Pizza",
            "Also Pizza",
            "Also Pizza",
            "Yummy Pizza",
            "Wrong Answer",
        ],
        Some(0),
    )
    .get_form_input("Form Title");

let food = match responses[2] {
    Index(0) => "Pizza",
    Index(1) => "Also Pizza",
    Index(2) => "Also Pizza",
    Index(3) => "Wrong Answer",
    _ => panic!("This person doesn't like pizza?!?"),
};

let interaction::FormResponses::String(last_name) = responses[0];
let interaction::FormResponses::String(first_name) = responses[1];

println!("{} {} likes {}", &first_name, &last_name, food);

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.