Struct menu::Runner

source ·
pub struct Runner<'a, I, T>
where I: Write,
{ pub interface: I, /* 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§

§interface: I

Implementations§

source§

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

source

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

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, context: &mut T)

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, I, T> Freeze for Runner<'a, I, T>
where I: Freeze,

§

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

§

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

§

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

§

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

§

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

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

§

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

§

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.