CliFrontend

Struct CliFrontend 

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

A frontend that uses stdin and stdout

Implementations§

Source§

impl CliFrontend

Source

pub fn new() -> Self

Create a new CliFrontend

Examples found in repository?
examples/counter.rs (line 49)
45fn main() {
46    run(
47        MyNode::Small,
48        &mut State { count: 0 },
49        &mut CliFrontend::new(),
50    );
51}
More examples
Hide additional examples
examples/rooms.rs (line 108)
104fn main() {
105    run(
106        Room::Start,
107        &mut State { has_key: false },
108        &mut CliFrontend::new(),
109    )
110    .command("save", |rt| {
111        match rt.save("rooms.yaml") {
112            Ok(_) => rt.println("Save complete"),
113            Err(e) => rt.println(format!("Error: {}", e)),
114        }
115        Continue
116    })
117    .command("load", |rt| {
118        match rt.load("rooms.yaml") {
119            Ok(_) => rt.println("Load complete"),
120            Err(e) => rt.println(format!("Error: {}", e)),
121        }
122        Skip
123    })
124    .command("inv, inventory", |rt| rt.push_node(Inventory));
125}
Source

pub fn with_bg_color(color: Color) -> Self

Create a new CliFrontend with the given background color

Trait Implementations§

Source§

impl Default for CliFrontend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Frontend for CliFrontend

Source§

fn background_color(&self) -> Color

Get the background color
Source§

fn set_background_color(&mut self, color: Color)

Set the background color
Source§

fn clear(&mut self)

Clear the display
Source§

fn print_colored<S: ToString>(&mut self, text: S, color: Color)

Print text to the display with the given color
Source§

fn newline(&mut self)

Print a newline to the display
Source§

fn input(&mut self) -> String

Get input from the user
Source§

fn print<S: ToString>(&mut self, text: S)

Print text to the display
Source§

fn println<S: ToString>(&mut self, text: S)

Print text and a newline to the display

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.