Struct menu::Runner

source ·
pub struct Runner<'a, T>where
    T: Write + 'a,{
    pub context: T,
    /* private fields */
}
Expand description

This structure handles the menu. You feed it bytes as they are read from the console and it executes menu actions when commands are typed in (followed by Enter).

Fields§

§context: T

The context object the Runner carries around.

Implementations§

source§

impl<'a, T> Runner<'a, T>where T: Write,

source

pub fn new(menu: Menu<'a, T>, buffer: &'a mut [u8], context: T) -> Runner<'a, T>

Create a new Runner. You need to supply a top-level menu, and a buffer that the Runner can use. Feel free to pass anything as the context type - the only requirement is that the Runner can write! to the context, which it will do for all text output.

source

pub fn prompt(&mut self, newline: bool)

Print out a new command prompt, including sub-menu names if applicable.

source

pub fn input_byte(&mut self, input: u8)

Add a byte to the menu runner’s buffer. If this byte is a carriage-return, the buffer is scanned and the appropriate action performed. By default, an echo feature is enabled to display commands on the terminal.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Runner<'a, T>where T: RefUnwindSafe,

§

impl<'a, T> Send for Runner<'a, T>where T: Send,

§

impl<'a, T> Sync for Runner<'a, T>where T: Sync,

§

impl<'a, T> Unpin for Runner<'a, T>where T: Unpin,

§

impl<'a, T> !UnwindSafe for Runner<'a, T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.