PromptBuilder

Struct PromptBuilder 

Source
pub struct PromptBuilder { /* private fields */ }
Expand description

Build a new prompt. history_max_items is how many items to store in the history. This defaults at 100. This is optional. app is the callbacks prefix is the prefix to show before the command

Implementations§

Source§

impl PromptBuilder

Source

pub fn builder() -> PromptBuilderBuilder<((), (), ())>

Create a builder for building PromptBuilder. On the builder, call .history_max_items(...)(optional), .app(...), .prefix(...) to set the values of the fields. Finally, call .build() to create the instance of PromptBuilder.

Examples found in repository?
examples/basic.rs (line 41)
35fn main() {
36    let chr = ColoredChar::builder().ch('>' as u8).foreground_color(Color::Yellow).build();
37    let prefix = ColoredString::new_from_inner(&[
38        chr, chr, chr,
39        ColoredChar::builder().ch(' ' as u8).build()
40    ]);
41    let mut prompt: Prompt = PromptBuilder::builder().prefix(prefix).app(Box::new(Cli {})).build().into();
42    prompt.run();
43}

Trait Implementations§

Source§

impl From<PromptBuilder> for Prompt

Source§

fn from(b: PromptBuilder) -> Self

Use PromptBuilder::into() to convert into a Prompt

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, 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.