Skip to main content

Builder

Struct Builder 

Source
pub struct Builder {
    pub state: String,
    pub name: String,
    pub kind: Kind,
    pub instructions: String,
    pub yes: String,
    pub no: String,
    pub options: Vec<(String, String)>,
    pub levels: Vec<String>,
    pub focus: usize,
    pub cursor: usize,
    pub message: Option<String>,
    pub existing: Vec<String>,
    /* private fields */
}

Fields§

§state: String§name: String§kind: Kind§instructions: String§yes: String§no: String§options: Vec<(String, String)>§levels: Vec<String>§focus: usize§cursor: usize§message: Option<String>§existing: Vec<String>

The names the session already holds, so the form can say what it would overwrite.

Implementations§

Source§

impl Builder

Source

pub fn new(state: String, name: &str) -> Self

Opens on the first field that still needs an answer: the state if there is none, the name if there is no name, otherwise the type.

Source

pub fn of_kind(self, kind: Kind) -> Self

Open on this type rather than a noul.

This is how a second question of the same type costs nothing to reach: after one is added the form reopens on the type just used, instead of falling back to a noul every time.

Source

pub fn over(self, existing: Vec<String>) -> Self

The names the session already holds; committing over one of them asks first.

Source

pub fn fields(&self) -> Vec<Field>

The focusable fields, in tab order, for the current question type.

Source

pub fn focused(&self) -> Field

Source

pub fn text(&self, field: Field) -> &str

Source

pub fn key(&mut self, key: KeyEvent) -> Outcome

Source

pub fn add_row(&mut self)

Ctrl-O, or Enter on the last row: one more option or level.

Source

pub fn delete_row(&mut self)

Ctrl-X: drop the row the cursor is on.

Source

pub fn preview(&self) -> Value

The question as it would go on the wire right now, incomplete parts included.

Source

pub fn as_command(&self) -> String

The equivalent one-line command, so builder mode teaches the fast path.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more