Struct ibuilder::Builder[][src]

pub struct Builder<T> { /* fields omitted */ }
Expand description

Interactive builder for creating instances of the struct T by communicating. To instantiate a new Builder for the type T, make T derive from IBuilder and call builder() on it from the Buildable trait.

Communication

After having instantiated a new Builder<T> you can call the get_options() method for fetching the list of possible actions that can be done to update the builder. Those options are like menu entries used to move between menus and set the value of the fields.

The Options struct contains a list of possible Choices (like buttons to press) and eventually allow raw text input (like a textbox). For example while editing an integer field the user can insert the new value of the number as a text or can choose to go back to the previous menu by pressing on “back”.

The user’s input is communicated to the Builder via the choose method. It takes an Input, a container with the choice of the user, which can be either some Text (if the Options allowed it), or a Choice (whose content is the identifier of the selected option between the ones in the Options).

When the user has filled all the fields of the builder, he can select the “done” options, which will make the choose method return Ok(Some(T)), signaling the end of the communication.

Implementations

Create a new builder from a BuildableValue. Note that the inner type of the BuildableValue must match T, otherwise a panic is very likely.

Return all the valid options that this builder accepts in the current state.

Apply an input to the builder, making it change state. Call again get_options() for the new options.

Returns Ok(None) if the process is not done yet, Ok(Some(T)) when the user choose to finish the builder.

If the process is done try to finalize the process, even if the user hasn’t completed the the selection yet.

Check if all the fields have been set and the call to finalize() will be successful.

Return the tree structure of the Builder internal state.

Trait Implementations

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

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.