Prompt

Trait Prompt 

Source
pub trait Prompt: Widget {
    type ValidateErr: Widget;
    type Output;

    // Required method
    fn finish(self) -> Self::Output;

    // Provided method
    fn validate(&mut self) -> Result<Validation, Self::ValidateErr> { ... }
}
Expand description

This trait should be implemented by all ‘root’ widgets.

It provides the functionality required only by the main controlling widget. For the trait required for general rendering to terminal, see Widget.

Required Associated Types§

Source

type ValidateErr: Widget

The error type returned by validate. It can be any widget and the render cycle is guaranteed to be called only once.

Source

type Output

The output type returned by Input::run

Required Methods§

Source

fn finish(self) -> Self::Output

The value to return from Input::run. This will only be called once validation returns Validation::Finish

Provided Methods§

Source

fn validate(&mut self) -> Result<Validation, Self::ValidateErr>

Determine whether the prompt state is ready to be submitted. It is called whenever the user presses the enter key.

See Validation

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.

Implementors§