[][src]Struct dbgcmd::Console

pub struct Console { /* fields omitted */ }

Methods

impl Console[src]

pub fn new() -> Self[src]

impl Console[src]

pub const fn enabled(&self) -> bool[src]

Whether the console is enabled. This will be false in release mode unless the force-enabled feature is switched on.

When this is false, all methods of the Console struct will do nothing and return only default values.

pub fn confirm<Cmd: FromStr>(&mut self) -> Result<Cmd, Cmd::Err>[src]

Tries to parse the text entered so far as the given type, and clear the entry.

This uses the FromStr trait to parse the entry. You should implement this trait on the type you're using for your commands.

pub fn entry(&self) -> &str[src]

Returns a reference to the text entered so far.

pub fn history(&self) -> impl Iterator<Item = &str>[src]

Returns an iterator over the previously confirmed entries. This yields items in the order from most recent to least recent.

pub fn history_deduped(&self) -> impl Iterator<Item = &str>[src]

The same as history, but will not yield the same entry twice in a row.

pub fn history_len(&self) -> usize[src]

Returns the number of items in the history. Note that this includes duplicate entries.

pub fn set_entry(&mut self, entry: String)[src]

Clears and sets the value of the entire command entry.

pub fn receive_char(&mut self, ch: char)[src]

Receive an individual character and append it to the command entry.

pub fn receive_char_if<F: Fn(char) -> bool>(
    &mut self,
    ch: char,
    filter: F
) -> bool
[src]

Receive an individual character and append it to the command entry if the filter argument returns true for it.

Useful for limiting which characters can be entered.

Examples

let mut console = dbgcmd::Console::new();

let ch = '?';
let accepted = console.receive_char_if(ch, char::is_alphanumeric);

assert!(!accepted);
assert!(console.entry().is_empty());

pub fn backspace(&mut self)[src]

Removes the last character of the command entry.

pub fn clear(&mut self)[src]

Clears the command entry.

pub fn clear_history(&mut self)[src]

Clears the entire command history.

pub fn up(&mut self) -> bool[src]

Cycles through the command history towards older entries.

Returns true if there was an older entry, and false if not. If there is no older entry, the cursor does not move.

pub fn up_deduped(&mut self) -> bool[src]

Cycles through the command history towards older entries, ignoring duplicates.

Returns true if there was an older entry that differs from the current entry.

pub fn down(&mut self) -> bool[src]

Cycles through the command history towards newer entries.

Returns true if there was a newer entry, including the current input. Returns false if there was no newer entry.

pub fn down_deduped(&mut self) -> bool[src]

Cycles through the command history towards newer entries, ignoring duplicates.

Returns true if there was a newer entry that differs from the current entry.

pub fn shown(&self) -> bool[src]

Whether or not the Console is in a visible state. This does not affect the functionality of any other method, and is intended to be used by you to decide whether or not to render the console.

pub fn show(&mut self)[src]

Sets the Console to be visible.

pub fn hide(&mut self)[src]

Sets the Console to be hidden.

pub fn toggle_shown(&mut self)[src]

Toggles the visible state of the Console.

Trait Implementations

impl Clone for Console[src]

impl Default for Console[src]

impl Eq for Console[src]

impl PartialEq<Console> for Console[src]

impl StructuralEq for Console[src]

impl StructuralPartialEq for Console[src]

Auto Trait Implementations

impl RefUnwindSafe for Console

impl Send for Console

impl Sync for Console

impl Unpin for Console

impl UnwindSafe for Console

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.