Struct Input

Source
pub struct Input<P, B: Backend> { /* private fields */ }
Expand description

A ui runner which implements the render cycle.

It renders and processes events with the help of a type that implements Prompt.

See run for more information

Implementations§

Source§

impl<P, B: Backend> Input<P, B>

Source

pub fn new(prompt: P, backend: &mut B) -> Input<P, &mut B>

Creates a new Input. This won’t do anything until it is run.

Source

pub fn hide_cursor(self) -> Self

Hides the cursor while running the input. This won’t do anything until it is run.

Source

pub fn on_esc(self, on_esc: OnEsc) -> Self

What to do after receiving a Esc.

For OnEsc::Terminate - an Error::Aborted will be returned. For OnEsc::SkipQuestion - the currently shown prompt will be cleared, and Ok(None) will be returned. For OnEsc::Ignore - no special behaviour will be applied to the Esc key. Like other keys, the Esc key will be passed to the prompt to handle.

Source§

impl<P: Prompt, B: Backend> Input<P, B>

Source

pub fn run<E>(self, events: &mut E) -> Result<Option<P::Output>>
where E: EventIterator,

Display the prompt and process events until the user presses Enter.

After the user presses Enter, validate will be called.

Trait Implementations§

Source§

impl<P: Debug, B: Debug + Backend> Debug for Input<P, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P, B> Freeze for Input<P, B>
where P: Freeze, B: Freeze,

§

impl<P, B> RefUnwindSafe for Input<P, B>

§

impl<P, B> Send for Input<P, B>
where P: Send, B: Send,

§

impl<P, B> Sync for Input<P, B>
where P: Sync, B: Sync,

§

impl<P, B> Unpin for Input<P, B>
where P: Unpin, B: Unpin,

§

impl<P, B> UnwindSafe for Input<P, B>
where P: UnwindSafe, B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.