Skip to main content

Tree

Struct Tree 

Source
pub struct Tree<C> { /* private fields */ }
Expand description

a tree of commands in modes

Implementations§

Source§

impl<C: Copy> Tree<C>

Source

pub fn new() -> Tree<C>

Source

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)

Source

pub fn mode_info(&self, m: ModeId) -> &Mode

Source

pub fn find_mode(&self, prompt: &str) -> Option<ModeId>

the mode with this prompt suffix (“(config-ext-nacl)#”; the first one made)

Source

pub fn prompt(&self, m: ModeId, host: &str) -> String

the prompt of a mode for a host name (“R1(config)#”)

Source

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

Source

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)

Source

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”)

Source

pub fn parse( &self, mode: ModeId, line: &str, names: &dyn Names, ) -> Result<Parsed<C>, Error>

the command a line of mode is

Source

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)

Source

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

Source

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.

Trait Implementations§

Source§

impl<C: Clone> Clone for Tree<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for Tree<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: Copy> Default for Tree<C>

Source§

fn default() -> Tree<C>

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

Auto Trait Implementations§

§

impl<C> Forget for Tree<C>

§

impl<C> Freeze for Tree<C>
where Vec<Node<C>>: Freeze,

§

impl<C> RefUnwindSafe for Tree<C>
where Vec<Node<C>>: RefUnwindSafe,

§

impl<C> Send for Tree<C>
where Vec<Node<C>>: Send,

§

impl<C> Sync for Tree<C>
where Vec<Node<C>>: Sync,

§

impl<C> Unpin for Tree<C>
where Vec<Node<C>>: Unpin,

§

impl<C> UnsafeUnpin for Tree<C>
where Vec<Node<C>>: UnsafeUnpin,

§

impl<C> UnwindSafe for Tree<C>
where Vec<Node<C>>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.