pub struct Tree<C> { /* private fields */ }Expand description
a tree of commands in modes
Implementations§
Source§impl<C: Copy> Tree<C>
impl<C: Copy> Tree<C>
pub fn new() -> Tree<C>
Sourcepub fn mode(
&mut self,
prompt: &str,
title: &str,
parent: Option<ModeId>,
no_help: Option<&str>,
) -> ModeId
pub fn mode( &mut self, prompt: &str, title: &str, parent: Option<ModeId>, no_help: Option<&str>, ) -> ModeId
a new mode; no: a “no” keyword negates its commands (no_help is its help text)
pub fn mode_info(&self, m: ModeId) -> &Mode
Sourcepub fn find_mode(&self, prompt: &str) -> Option<ModeId>
pub fn find_mode(&self, prompt: &str) -> Option<ModeId>
the mode with this prompt suffix (“(config-ext-nacl)#”; the first one made)
Sourcepub fn prompt(&self, m: ModeId, host: &str) -> String
pub fn prompt(&self, m: ModeId, host: &str) -> String
the prompt of a mode for a host name (“R1(config)#”)
Sourcepub fn add(
&mut self,
mode: ModeId,
path: &str,
help: &str,
cmd: Option<C>,
flags: u8,
) -> NodeId
pub fn add( &mut self, mode: ModeId, path: &str, help: &str, cmd: Option<C>, flags: u8, ) -> NodeId
adds a command path: help describes its last word; cmd makes the command complete
there; flags (F_NO, F_HIDDEN) go to the last word
Sourcepub fn add_no(&mut self, mode: ModeId, path: &str, cmd: C)
pub fn add_no(&mut self, mode: ModeId, path: &str, cmd: C)
the no-form of a command may end at path (“no ip address” without an address)
Sourcepub fn also(&mut self, mode: ModeId, path: &str, target: &str)
pub fn also(&mut self, mode: ModeId, path: &str, target: &str)
after path, the words that follow target may follow as well (a list of options in
any order: “ping A repeat 5 size 100”)
Sourcepub fn parse(
&self,
mode: ModeId,
line: &str,
names: &dyn Names,
) -> Result<Parsed<C>, Error>
pub fn parse( &self, mode: ModeId, line: &str, names: &dyn Names, ) -> Result<Parsed<C>, Error>
the command a line of mode is
Sourcepub fn help(&self, mode: ModeId, line: &str, names: &dyn Names) -> Help
pub fn help(&self, mode: ModeId, line: &str, names: &dyn Names) -> Help
the answer to “?” typed right after line (a partly typed last word lists what it may
become; after a space, what may follow)
Sourcepub fn complete(
&self,
mode: ModeId,
line: &str,
names: &dyn Names,
) -> Completion
pub fn complete( &self, mode: ModeId, line: &str, names: &dyn Names, ) -> Completion
Tab: the last, partly typed word written out when only one keyword or name type fits
Sourcepub fn knows_first(&self, mode: ModeId, line: &str) -> bool
pub fn knows_first(&self, mode: ModeId, line: &str) -> bool
does the first word of a line name a command of mode (a keyword or the “no” of the
mode, abbreviations included)? An IOS-like EXEC answers unknown first words with a host
name lookup instead of the marker.